How can you achieve nested Masterpages in 2.0?

Answer Posted / amirtha

Master pages can be nested, with one master page
referencing another as its master. Nested master pages
allow you to create componentized master pages.
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.

Examples:
This is the parent Master Page:

<% @ Master Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html >
<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 Page:

<%@ 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 the child file that references the child master
page:

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



Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to you can limit Access to Web API to Specific HTTP Verb?

672


What does it mean your session has timed out?

533


In a webservice, need to display 10 rows from a table. Which is the best choice among datareader or dataset?

658


Is asp.net is a programming language?

498


What is asp.net? How is it different from asp?

544






Hello, Using Visual Studio 2005 (VB) I am working to create a Web Site implementing the following: Within a gridView I have placed a dropdownlist control with a DataSourceID="SDSLkupList". SDSLkupList is a sqlDataSource used to store a lookup list for dropdownlist translation from ID to text. SDSLkupList contains the translation text and other fields related to the dropdown selection ID. (Thought it would be efficient to get everything at the same time.) I would like to provide the user the ability to select from the dropdownlist and, based on the selection, use labels to list related columns stored on the SDSLkupList in separate gridView columns. I have read that SqlDataSources are not meant to be used for individual controls. Since SDSLkupList contains all related information, is there a way to do a find using the dropdownlist selectedValue? (I was not able to discover one.) Otherwise, what should I use? It would need to set the labels on the gridView DataRowBound event as well as the SelectedIndexChanged events. Has anyone done this? Any help would be appreciated. Thanks in Advance. Neal

1380


How can you handle errors in Web API?

600


How do I force the dispose method to be called automatically, as clients can forget to call dispose method?

515


Explain the main function of url routing system in asp.net mvc? : asp.net mvc

498


What is voluum?

544


COM+ Used ________________ Isolation Level

1530


can we remote debug applications with the remote debugger installed with vs.net 2002, with vs.net 2003?

1755


Can we handle the error and redirect to some pages using web.config?

924


What are the session management techniques asp net?

567


Can you set the session out time manually?

388