asp.net masterpages


<%@ Master Language="C#" 
AutoEventWireup="true" 
CodeFile="SimpleMasterPage.master.cs" 
Inherits="MasterPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    
    <div>
        <asp:contentplaceholder id="bodyContent" runat="server">
        </asp:contentplaceholder>
    </div>
    </form>
</body>
</html>

a master page is a collection "contentplaceholder" controls


<%@ Page Language="C#" AutoEventWireup="true" 
 CodeFile="basic-well-locations-mp.aspx.cs" Inherits="well_locations" 
 MasterPageFile="~/masterpages/SatyaMasterPage.master"%>

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

Notice the simipler structure of the content page

The "content" goes into the "contentplaceholder"

The "contentplaceholderid" of the "content" ties with the "id" of the contentplaceholder tag

you can treat a content page as the child of the master page

a child carries the content tag and the master carries the contentplaceholder


<%@ Master Language="C#" 
     MasterPageFile="~/masterpages/SatyaMasterPage.master"
    AutoEventWireup="true" 
    CodeFile="SatyaPageMenuMasterPage.master.cs" 
    Inherits="masterpages_SatyaPageMenuMasterPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="aspireContent" runat="server">
<table id="contentTableId" width="100%">
<tr>
<td id="contentMainCellId"  width="80%">
<asp:ContentPlaceHolder id="PageContentId" runat="server">
</asp:ContentPlaceHolder>
</td>
<td id="contentPageMenuCellId" width="20%">
<asp:ContentPlaceHolder id="PageMenuContentId" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
</asp:Content>

A nested page introduces new content ids and satisfies parent content ids


<%@ Page Language="C#" AutoEventWireup="true" 
CodeFile="TestMasterPage.aspx.cs" Inherits="test_TestMasterPage" 
 MasterPageFile="~/masterpages/SatyaPageMenuMasterPage.master"%>

<asp:Content ID="Content1" 
     ContentPlaceHolderID="PageContentId" runat="server">
<p>Hello Page Content Id</p>
</asp:Content>

<asp:Content ID="Content2" 
    ContentPlaceHolderID="PageMenuContentId" runat="server">
<p>Hello Page Menu Id</p>
</asp:Content>