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

Comment (1)

  • Mohamed Gamal Reply

    M.Gamal (and this is smart code )

    [c#]
    ontxtName textChanged event

    btnOK.Enabled=(txtName.Text !=””)

    September 27, 2009 at 7:13 PM

Leave a Reply

Your email address will not be published. Required fields are marked *