摘要:如何在 MasterPage裡 Body 增加屬性
如果想ContentPage裡想在MasterPage裡的Body增加屬性或設定
先在MasterPage的BODY增加
<Body id="MasterBody" runat="server">
在MasterPage.cs
新增建構子
因為BODY是HTML使用HtmlControl
需先引用System.Web.UI.HtmlControls;
public HtmlGenericControl BodyTag
{
get {renturn MasterBody;}
set { MasterBody = value;}
}
ContentPage.aspx
<%@ MasterType TypeName="MasterPage" %>
ContentPage.cs
this.Master.BodyTag.ID= "Page1";
這樣就抓的到了