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

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

Share this post