M
Mark Rae
Hi,
It's easy enough to get a content page to refer to public properties on its
associated master page e.g.
public partial class master_secure : System.Web.UI.MasterPage
{
public Label MyLabel = new Label();
}
To refer to the label from a content placeholder, you would do the
following:
((master_secure)Master).MyLabel.Text = "Hello world";
It's also easy enough to change a content page's associated master page in
code e.g.
private void Page_PreInit(object sender, System.EventArgs e)
{
this.MasterPageFile = "~/master/" + Session["MasterPage"].ToString() +
".master";
}
Is there a way to "combine" the two i.e. change a content page's master page
and then be able to refer to the newly associated master page's public
properties? It's obviously easy enough to refer to the newly associated
master page's controls by using the FindControl() method, but I'm wracking
my brains about how to refer to its public properties.
Clearly, I could create a new base class which inherited MasterPage and add
the extra properites to that, but is there a simpler way?
Any assistance gratefully received.
Mark
It's easy enough to get a content page to refer to public properties on its
associated master page e.g.
public partial class master_secure : System.Web.UI.MasterPage
{
public Label MyLabel = new Label();
}
To refer to the label from a content placeholder, you would do the
following:
((master_secure)Master).MyLabel.Text = "Hello world";
It's also easy enough to change a content page's associated master page in
code e.g.
private void Page_PreInit(object sender, System.EventArgs e)
{
this.MasterPageFile = "~/master/" + Session["MasterPage"].ToString() +
".master";
}
Is there a way to "combine" the two i.e. change a content page's master page
and then be able to refer to the newly associated master page's public
properties? It's obviously easy enough to refer to the newly associated
master page's controls by using the FindControl() method, but I'm wracking
my brains about how to refer to its public properties.
Clearly, I could create a new base class which inherited MasterPage and add
the extra properites to that, but is there a simpler way?
Any assistance gratefully received.
Mark