3D printing Aerodynamic engineering Aeronautical engineering Aeronautical engineering books Airports Architecture Artificial intelligence Automobiles Blast Resistant Design Books Bridges Building Codes Cabin Systems Civil Engineering Codes Concrete Conferences Construction Management Construction Materials Cooling Cryptocurrency Dams Do it Yourself Docks and Harbours Downloads Earthquake Engineering Electronics Engineering Engines Environmental Design & Construction Environmental Engineering Estimation Fluid Mechanics Fluid Mechanics Books Formwork design foundation engineering General Geotech Books Geotechnical Engineering Global Positioning System HVAC Hydraulics Hydraulics Books Hydro Power Hydrology Irrigation Engineering Machinery Magazines Management Books Masonry Mechanical Engineering Mechanics Mechanics Books Miscellaneous Books Modern Steel Construction Nanotechnology Natural Hazards Network Security Engineer Networking Systems News Noise and Attenuation Nuclear Engineering Nuclear Hazards to Buildings Pavement Design Prestressed Concrete Project Management Project Management Books Quantity Survey Quantity Survey Books railways RCC Structural Designing Remote Sensing Remote Sensing and GIS Books Renewable Energy Reports Resume Roads scholarships Smart devices Software Software Engineering Soil Mechanics Solar Energy Special Concrete Spreadsheets Steel Steel Spreadsheets Structural Analyses structures Structures Books Surveying Surveying Books Testing Thermodynamics Thesis Transportation Books Transportation Engineering Tunnel Engineering Wind Energy Zero Energy Buildings

Nested ASP.NET Master Pages

Master pages can be nested, with one master page referencing another as its master. Nested master pages allow you to create componentized master pages. For example, a large site might contain an overall master page that defines the look of the site. Different site content partners can then define their own child master pages that reference the site master and that in turn define the look for that partner's content.
A child master page has the file name extension .master, as with any master page. The child master page typically contains content controls that are mapped to content placeholders on the parent master page. In this respect, the child master page is laid out like any content page. However, the child master page also has content placeholders of its own to display content supplied by its own child pages. The following three page listings show a simple nested master page configuration.
This is the parent master file:

C#

<% @ Master Language="C#" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 
    1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
<form id="Form1" runat="server">
<div>
<h1>Parent Master</h1>
<p style="font:color=red">This is parent master content.</p>
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</div>
</form>
</body>
</html>

VB

<% @ Master Language="VB" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<head runat="server">
    <title>Untitled Page</title>
</head>
<form id="Form1" runat="server">
<div>
<h1>Parent Master</h1>
<p style="font:color=red">This is parent master content.</p>
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</div>
</form>
</body>
</html>
This is the child master file:

C#

<%@ Master Language="C#" MasterPageFile="~/Parent.master"%> 
<asp:Content id="Content1" ContentPlaceholderID="MainContent" runat="server">
   <asp:panel runat="server" id="panelMain" backcolor="lightyellow">
   <h2>Child master</h2>
      <asp:panel runat="server" id="panel1" backcolor="lightblue">
        <p>This is child master content.</p>
        <asp:ContentPlaceHolder ID="ChildContent1" runat="server" />
      </asp:panel>
      <asp:panel runat="server" id="panel2" backcolor="pink">
         <p>This is child master content.</p>
         <asp:ContentPlaceHolder ID="ChildContent2" runat="server" />
      </asp:panel>
      <br />
   </asp:panel>
</asp:Content>

VB

<%@ Master Language="VB" MasterPageFile="~/Parent.master"%> 
<asp:Content id="Content1" ContentPlaceholderID="MainContent" runat="server">
   <asp:panel runat="server" id="panelMain" backcolor="lightyellow">
   <h2>Child master</h2>
      <asp:panel runat="server" id="panel1" backcolor="lightblue">
        <p>This is childmaster content.</p>
        <asp:ContentPlaceHolder ID="ChildContent1" runat="server" />
      </asp:panel>
      <asp:panel runat="server" id="panel2" backcolor="pink">
         <p>This is childmaster content.</p>
         <asp:ContentPlaceHolder ID="ChildContent2" runat="server" />
      </asp:panel>
      <br />
   </asp:panel>
</asp:Content>
This is a child file that references the child master page:

C#

<%@ Page Language="C#" MasterPageFile="~/Child.master"%>
<asp:Content id="Content1" ContentPlaceholderID="ChildContent1" runat="server">
   <asp:Label runat="server" id="Label1" 
        text="Child label1" font-bold="true" />
   <br />
</asp:Content>
<asp:Content id="Content2" ContentPlaceholderID="ChildContent2" runat="server">
   <asp:Label runat="server" id="Label2" 
        text="Child label2" font-bold="true"/>
</asp:Content>
 
VB

<%@ Page Language="VB" MasterPageFile="~/Child.master"%>
<asp:Content id="Content1" ContentPlaceholderID="ChildContent1" runat="server">
   <asp:Label runat="server" id="Label1" 
        text="Child label1" font-bold="true" />
   <br>
</asp:Content>
<asp:Content id="Content2" ContentPlaceholderID="ChildContent2" runat="server">
   <asp:Label runat="server" id="Label2" 
        text="Child label2" font-bold="true"/>
</asp:Content>

[blogger]

Author Name

Engineeersdaily

Contact Form

Name

Email *

Message *

Powered by Blogger.