由于项目的需要,正式的开始使用VS2005,以前也只是看过一些相关的内容,为了加强一下记忆,特此开始.NET2.0的学习笔记系列。
   

弱类型:使用FindControl方法。
强类型:在母版页中定义属性,内容页通过属性访问母版页中的内容。

访问母版页中的控件(弱类型)
In the master page…
<asp:Label ID="Title" RunAt="server" />
In the content page…
((Label) Master.FindControl ("Title")).Text = "Orders";

访问母版页中的控件(强类型)
In the master page…
<asp:Label ID="Title" RunAt="server" />
  .
  .
  .
<script language="C#" runat="server">
public string TitleText
{
    get { return Title.Text; }
    set { Title.Text = value; }
}
</script>

In the content page…
((Site)Master).TitleText = "Orders";


 


相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
  • 2022-12-23
  • 2021-11-15
  • 2022-12-23
猜你喜欢
  • 2022-02-25
  • 2021-09-14
  • 2022-12-23
  • 2022-01-15
  • 2022-02-15
  • 2022-12-23
相关资源
相似解决方案