Proper referencing Master page props from custom control
ASPX Page has Master page declared.
In Master page there is property IsHistory.
Page has custom control.
Custom control has to get access to IsHistory prop of Master.
Possible solutions:
- Create interface that describes GetIsHistory and implement it on MasterPage. Then from custom control cast Page.Master to interface and obtain prop value
- Alternatively and more object approached:
MasterPage.Init
IsHistory = true;
Page.aspx
<%@ MasterType TypeName="SiteMaster" %>
protected void Page_Init(object sender, EventArgs e)
{
uc1.IsHistory = Master.IsHistory;
}
CustomControl.ascx
public bool IsHistory { get; set; }
<h2><%:IsHistory.ToString()%></h2>