첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

■ MasterPage 클래스 : 마스터 페이지 사용하기

------------------------------------------------------------------------------------------------------------------------


TestProject.zip


Site.css

 

 

body

{

    padding-top    : 50px;

    padding-bottom : 20px;

}

 

.body-content

{

    padding-left  : 15px;

    padding-right : 15px;

}

 

 

MainPage.aspx

 

 

<%@ Page

    Title="MasterPage 클래스 : 마스터 페이지 사용하기"

    Language="C#"

    MasterPageFile="~/MainMasterPage.Master"

    AutoEventWireup="true"

    CodeBehind="MainPage.aspx.cs"

    Inherits="TestProject.MainPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeaderContent" runat="server" />

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <div class="jumbotron">

        <h1>메인 페이지</h1>

        <p>마스터 페이지, 레이아웃 페이지 등의 표현 방법은 웹 사이트 공통 레이아웃을 정의하는 기능입니다.</p>

    </div>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="FooterContent" runat="server" />

 

 

AboutPage.aspx

 

 

<%@ Page

    Title="정보 페이지"

    Language="C#"

    MasterPageFile="~/MainMasterPage.Master"

    AutoEventWireup="true"

    CodeBehind="AboutPage.aspx.cs"

    Inherits="TestProject.AboutPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeaderContent" runat="server" />

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>정보 페이지</h2>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="FooterContent" runat="server" />

 

 

ContactPage.aspx

 

 

<%@ Page

    Title="연락처 페이지"

    Language="C#"

    MasterPageFile="~/MainMasterPage.Master"

    AutoEventWireup="true"

    CodeBehind="ContactPage.aspx.cs"

    Inherits="TestProject.ContactPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeaderContent" runat="server" />

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>연락처 페이지</h2>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="FooterContent" runat="server" />

 

 

MainMasterPage.Master

 

 

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MainMasterPage.Master.cs" Inherits="TestProject.MainMasterPage" %>

<!DOCTYPE html>

<html lang="ko">

    <head runat="server">

        <meta charset="utf-8" />

        <meta name="viewport" content="width=device-width, initial-scale=1.0" />

        <title></title>

        <link href="Content/bootstrap.css" rel="stylesheet" />

        <link href="Content/Site.css"      rel="stylesheet" />

        <asp:ContentPlaceHolder ID="HeaderContent" runat="server" />

    </head>

    <body>

        <form id="form" runat="server">

            <div class="navbar navbar-inverse navbar-fixed-top">

                <div class="container">

                    <div class="navbar-header">

                        <button type="button" class="navbar-toggle"

                            data-toggle="collapse" data-target=".navbar-collapse">

                            <span class="icon-bar" />

                            <span class="icon-bar" />

                            <span class="icon-bar" />

                        </button>

                        <a class="navbar-brand" runat="server" href="~/MainPage.aspx">마스터 페이지</a>

                    </div>

                    <div class="navbar-collapse collapse">

                        <ul class="nav navbar-nav">

                            <li><a runat="server" href="~/MainPage.aspx"></a></li>

                            <li><a runat="server" href="~/AboutPage.aspx">정보</a></li>

                            <li><a runat="server" href="~/ContactPage.aspx">연락처</a></li>

                        </ul>

                        <ul class="nav navbar-nav navbar-right">

                            <li><a runat="server" href="~/Account/Register">등록</a></li>

                            <li><a runat="server" href="~/Account/Login">로그인</a></li>

                        </ul>

                    </div>

                </div>

            </div>

            <div class="container body-content">

                <asp:ContentPlaceHolder ID="MainContent" runat="server" />

                <hr />

                <footer>

                    <p>&copy; <%: DateTime.Now.Year %> - ASP.NET 웹 프로젝트</p>

                </footer>

            </div>

            <script src="Scripts/jquery-1.9.1.js" />

            <script src="Scripts/bootstrap.js"    />

            <asp:ContentPlaceHolder ID="FooterContent" runat="server" />

        </form>

    </body>

</html>

 

------------------------------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG , ,

댓글을 달아 주세요