asp.net masterpages

satya - Tuesday, May 22, 2007 10:42:56 PM

A simple master page


<%@ 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>

satya - Tuesday, May 22, 2007 10:44:06 PM

a master page is a collection "contentplaceholder" controls

a master page is a collection "contentplaceholder" controls

satya - Tuesday, May 22, 2007 10:46:35 PM

structure of a page using the master page


<%@ 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>

satya - Tuesday, May 22, 2007 10:47:03 PM

Notice the simipler structure of the content page

Notice the simipler structure of the content page

satya - Tuesday, May 22, 2007 10:48:24 PM

contentplaceholder and content tags

The "content" goes into the "contentplaceholder"

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

satya - Tuesday, May 22, 2007 10:48:54 PM

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

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

satya - Tuesday, May 22, 2007 10:49:53 PM

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

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

satya - Tuesday, May 22, 2007 10:50:41 PM

masterpages can be nested


<%@ 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>

satya - Tuesday, May 22, 2007 10:52:46 PM

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

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

satya - Tuesday, May 22, 2007 11:11:27 PM

Sample page using the above nested master page


<%@ 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>