How to Use Nested MasterPage
Following code will show how to implement nested master page step by step:
parent.master markup code:
<% @ Master Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> <head id="Head1" 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>
child.master markup code:
<%@ 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>
child.aspx markup code:
<%@ 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>
No comments:
Post a Comment
Thank You for Your Comments. We will get back to you soon.