Access Master Pages Properties
There are different techniques to access MasterPages properties
Master Page
Code file:
public partial class MyMasterPageClass: System.Web.UI.MasterPage
{
public string ErrorMessage
{
set
{
lblErrorPane.Text = value;
panelErrorMessage.Visible = true;
}
}
}
Content Page
Master Page
Code file:
public partial class MyMasterPageClass: System.Web.UI.MasterPage
{
public string ErrorMessage
{
set
{
lblErrorPane.Text = value;
panelErrorMessage.Visible = true;
}
}
}
Content Page
1) ((MyMasterPageClass)Master).ErrorMessage = " Test Error Message";
After adding this <%@ MasterType VirtualPath="~/MasterPage.master" %> under Page Directive you can access the property of master page directly.
2) this.Master.ErrorMessage = "Test Message";
Comments