母版页

1. 在整个站点中应用母版页 

<configuration>
  <system.web>
    <pages masterPageFile="~/Site.master" />
  </system.web>
</configuration>

2.动态应用母版页

void Page_PreInit (Object sender, EventArgs e)
{
    Page.MasterPageFile = "~/Site.master";
}

3.操作模板页中的控件(两种方式:强类型与弱类型)

 

母版页母版页代码

强类型:

<asp:Label ID="Title" RunAt="server" />
.
.
.
<script language="C#" runat="server">
public string TitleText
{
get { return Title.Text; }
set { Title.Text = value; }
}
</script>



Master.TitleText
= "Orders";


弱类型:
<asp:Label ID="Title" RunAt="server" />


((Label) Master.FindControl (
"Title")).Text = "Orders";

              

 

 

 
上一篇:JavaScript replace() 方法


下一篇:特殊权限set_uid,set_gid,stick_bit,软硬链接