all groups > asp.net > september 2006 >
You're in the

asp.net

group:

Master Page


Master Page Weston Fryatt
9/30/2006 10:48:03 PM
asp.net: Can you change text or add controls dynamically on a Master Page (not in the
Content Place Holder)?

Re: Master Page Mark Rae
10/1/2006 8:53:20 AM
[quoted text, click to view]

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";

Re: Master Page Jesse Liberty
10/1/2006 10:59:21 AM
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";




--

Jesse Liberty
Author, Programmer
Microsoft MVP


[quoted text, click to view]

Re: Master Page Mark Rae
10/1/2006 4:20:27 PM
[quoted text, click to view]

Of course. A class is a class is a class...

AddThis Social Bookmark Button