Use of Nested Master Page in Asp.net

Category: ASP.NETMASTER PAGE Comments: No comments

Use of Nested Master Page in Asp.net

********************************We cannot Run Master Page Directly.**************************

First Master Page

<%@ Master Language=”C#” AutoEventWireup=”true” CodeFile=”MasterPage.master.cs” Inherits=”MasterPage” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
<title></title>
<asp:ContentPlaceHolder id=”headParent” runat=”server”>
</asp:ContentPlaceHolder>
</head>
<body>
<form id=”form1″ runat=”server”>
<div style=”width:620px;height:500px;border:1px solid black”>
Welcome to primary Master Page
<asp:ContentPlaceHolder id=”ContentPlaceHolderParent” runat=”server”>

</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
Second Master Page

<%@ Master Language=”C#” MasterPageFile=”~/MasterPage.master” AutoEventWireup=”true” CodeFile=”MasterPage2.master.cs” Inherits=”MasterPage2″ %>

<asp:Content ID=”Content1″ ContentPlaceHolderID=”headParent” Runat=”Server”>
</asp:Content>
<asp:Content ID=”Content2″ ContentPlaceHolderID=”ContentPlaceHolderParent” Runat=”Server”>
<asp:ContentPlaceHolder ID=”Test” runat=”server”>
<div style=”border:1px solid black; width:200px;height:200px;”>
</div>
</asp:ContentPlaceHolder>
</asp:Content>
Test Page To Test

<%@ Page Title=”" Language=”C#” MasterPageFile=”~/MasterPage2.master” AutoEventWireup=”true” CodeFile=”test.aspx.cs” Inherits=”test” %>
<asp:Content ID=”Test12″ runat=”server” ContentPlaceHolderID=”Test”>
<div style=”border:1px solid black; width:400px;height:400px; margin-left:100px;margin-top:76px”>
Welocme to Secondary Master Page
<asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox>
</div>
</asp:Content>

nestedMasterDownload Nested Master Page

Leave a Reply

Your email address will not be published. Required fields are marked *

*

HTML tags are not allowed.