Master Page

  • Thread starter Thread starter Weston Fryatt
  • Start date Start date
W

Weston Fryatt

Can you change text or add controls dynamically on a Master Page (not in the
Content Place Holder)?
 
Can you change text or add controls dynamically on a Master Page (not in
the Content Place Holder)?

Yes - a MasterPage is really just a particular kind of UserControl.

So, e.g. if the MasterPage had a Label called "lblHeading", you could do the
following in the Page_Load method of the ContentPage:

((Label)this.Master.FindControl("lblHeading")).Text = "Hello world";
 
Yes, but if you anticipate it in advance, you can make the label's text a
property of the master page

public string LblHeading
{
get { return this.lblHeading.Text; }
set { this.lblHeading.Text = value; }
}

Then, in the content page, all you have to write is

this.Master.LblHeading = "Hello World";
 
Yes, but if you anticipate it in advance, you can make the label's text a
property of the master page

public string LblHeading
{
get { return this.lblHeading.Text; }
set { this.lblHeading.Text = value; }
}

Then, in the content page, all you have to write is

this.Master.LblHeading = "Hello World";

Of course. A class is a class is a class...
 
Back
Top