In nested master pages child master pasge code behind not working properly..
if i debug and set a stopper in child master page code behind file its not working..
Following is my code:
here is main master page html code
<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="AdminMaster.master.cs"
Inherits="Admin_AdminMaster" %>
<!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>Untitled Page</title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div class="mainouter">
<div class="Contents">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</div>
</form>
</body>
</html>
here is the child master page html code
<%@ Master Language="C#" MasterPageFile="~/Admin/AdminMaster.master"
AutoEventWireup="false"
CodeFile="AdCommercialDetail.master.cs" Inherits="Admin_AdCommercialDetail" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2"
ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<table style="width: 100%;">
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</td>
<td>
fdgsdf
</td>
<td>
dfgfdg
</td>
</tr>
</table>
</asp:Content>
code behind of master page
public partial class Admin_AdminMaster : System.Web.UI.MasterPage {
protected void Page_Load(object sender, EventArgs e)
{
}
}
code behind of child master page
public partial class Admin_AdCommercialDetail :
System.Web.UI.MasterPage {
SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase("ConnectionString");
protected void Page_Load(object sender, System.EventArgs e)
{
this.Label1.Text = "gfjhfhggggggggggggggggg";
Label1.Text = "fgdjgjhghklgfsaddffgghhjjkdsdfghjk";
}
}
Here in your child master place the controls outside the ContentPlaceHolder like,
<%@ Master Language="C#" MasterPageFile="~/Admin/AdminMaster.master"
AutoEventWireup="false"
CodeFile="AdCommercialDetail.master.cs" Inherits="Admin_AdCommercialDetail" %>
<table style="width: 100%;">
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</td>
<td>
fdgsdf
</td>
<td>
dfgfdg
</td>
</tr>
</table>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
</asp:Content>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.