Tuesday, February 3, 2009

How to Access controls on Master Pages from Content Pages in ASP .NET

We will assume that we have a Label control called "Label1" on your Master Page, you might want to change the text of that Label.
To do that write this code in your content page:

Label lbl = new Label();
lbl = (Label)Master.FindControl("Label1");
lbl.Text = "Text";

Of course, this is all assuming the label is OUTSIDE the ContentPlaceHolder

Hire Me

Follow me on Facebook

Follow me

Do you find this Blog helpful?

Follow by Email

About Me

My Photo
Expert Senior Software Developer

Microsoft Business Card