重写Master控件的属性
时间:2011-06-14 来源:丘伟国
Master 的控件 和属性:
1 <script runat="server">
2 protected void Page_Load(object sender, EventArgs e)
3 {
4 if (!Page.IsPostBack)
5 {
6 Label1.Text = System.Guid.NewGuid().ToString();
7 }
8 }
9
10 string m_PageHeadingTitle = "My Company";
11
12 public string PageHeadingTitle
13 {
14 get
15 {
16 return m_PageHeadingTitle;
17 }
18 set
19 {
20 m_PageHeadingTitle = value;
21 }
22 }
23 </script>
引用页面 改变Master 的控件 和属性:
<%@ Page Language="C#" MasterPageFile="~/Wrox.master" %>
<%@ MasterType VirtualPath="~/Wrox.master" %>
<script runat="server" language="C#">
protected void Page_Load(object sender, EventArgs e)
{
Master.MasterPageLabel1.Font.Size = 25;
(Master.FindControl("Label1")as Label).Text="8888";
}
</script>
相关阅读 更多 +