Friday, 7 December 2012

How to Use Nested MasterPage

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#" %>


    1.1//EN" "">


<head id="Head1" runat="server">

    <title>Untitled Page</title>



    <form id="Form1" runat="server">



            Parent Master</h1>

        <p style="font: color=red">

            This is parent master content.</p>

        <asp:ContentPlaceHolder ID="MainContent" runat="server" />





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">


            Child master</h2>

        <asp:Panel runat="server" ID="panel1" BackColor="lightblue">


                This is child master content.</p>

            <asp:ContentPlaceHolder ID="ChildContent1" runat="server" />


        <asp:Panel runat="server" ID="panel2" BackColor="pink">


                This is child master content.</p>

            <asp:ContentPlaceHolder ID="ChildContent2" runat="server" />


        <br />



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 ID="Content2" ContentPlaceHolderID="ChildContent2" runat="server">

    <asp:label runat="server" id="Label2" text="Child label2" font-bold="true" />




No comments:

Post a Comment

Thank You for Your Comments. We will get back to you soon.

back to top