Master page made the developers life extremely easy where all of the core design (specially headers, footers etc) can be designed and defined in one page which then can be inherited by all the pages in the application without requiring adding the header, footers etc explicitly. However master pages can also be nested, that is in a application, where are there two (or more) set of designs to be followed in two or more set of pages, along with following some common design components (such as header, footer etc) among all the pages in the system. In that case, we will create a main master page which will contain all common design components, and then will create separate nested master pages that will includes specialized designs for specific sets of pages.
Here is a sample for the main master page:
<%@ Master %>
<html>
<head id="Head1" runat="server">
<title>Title</title>
</head>
<body>
<form id="form1" runat="server">
<div class="content">
Some content in main master page
<div >
<asp:ContentPlaceHolder ID="ContentPlaceHolder1"
runat="server">
Child master page will be placed here...
</asp:ContentPlaceHolder>
</div>
</div>
</form>
</body>
</html>
Here is a sample for the nested master page:
<%@ Master MasterPageFile="~/master/employee.master"%>
<asp:Content ID="Content1" runat="server"
ContentPlaceHolderID="ContentPlaceHolder1">
<table width="100%">
<tr width="100%">
<td width="100%">
This is child master page<br />
</td>
</tr>
<tr width="100%">
<td width="100%">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1"
runat="server" EnableViewState="true">
Contents of pages...
</asp:ContentPlaceHolder>
<br/>
Content in Child master page.
<br/>
<asp:ContentPlaceHolder ID="ContentPlaceHolder2"
runat="server" EnableViewState="true">
Contents of pages.
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
</asp:Content>
Here is a sample page that uses the nested master page:
<%@ Page Language="VB" MasterPageFile="~/master/default.master"
Title="Using inherited master page..." %>
<asp:Content ID="Content1"
ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div class="contentcontainerDIV">
<div class="headerDIV">
<br />
<h3>
Some content on page
</h3>
<p class="ContentText">
Some content on page
</p>
</div>
</div>
</asp:Content>
<asp:Content ID="Content2"
ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
<div class="contentcontainerDIV">
<div class="headerDIV">
<br />
<h3>
Some content on page
</h3>
<p class="ContentText">
Some content on page
</p>
</div>
</div>
</asp:Content>
Download sample: