让我们重头嚼起
使用母版页:
<!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>
</head>
<body>
<form id="form1" runat="server">
<!-- 母板页头 star -->
<div id="header" style="border:2px solid blue;margin-top:10px;padding:10px" mce_style="border:2px solid blue;margin-top:10px;padding:10px">
母板页头<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
<!-- 母板页头 end -->
<!-- 母板页主体内容 star -->
<div>
<asp:contentplaceholder id="MasterPageContent" runat="server">
</asp:contentplaceholder>
</div>
<!-- 母板页主体内容 end -->
<!-- 母板页脚 star -->
<div id="footer" style="border:2px solid blue;margin-top:10px;padding:10px" mce_style="border:2px solid blue;margin-top:10px;padding:10px">
母板页脚
</div>
<!-- 母板页脚 end -->
</form>
</body>
</html>
子页面:
子页面后台:
this.Master.TextBoxVisible = false; //访问母版页中定义的属性值
TextBox tb = (TextBox)this.Master.FindControl("TextBox1"); //访问母版页中控件
后续补充:
可在母版页的<head></head>标签中插入内容,以便为各子页自由包含引入文件
母版:
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
子页: