access content page controls from within the master page

  • Thread starter Thread starter phil1bruening
  • Start date Start date
P

phil1bruening

Hello!
I need to access content page controls from within the master page.
How can I do that??
 
Thanks, but I need to access to the content page from the master page.
Now I have programed it like this:
The Label1 is in the Content Page, this Source is in the MasterPage.
in the Page Load:
if (Page.title=="MyContentPage")
{
GetControls(this, "Label1");
Label myLabel = (Label)Convert.ChangeType(myC,
typeof(Label));
myLabel.Text = "other Text";
}
the procedure GetControls:
public void GetControls(Control c, string FindControl)
{


foreach (Control cc in c.Controls)
{

if (cc.ID == FindControl)
{
myC = cc;
break;

}

if (cc.Controls.Count>0)
GetControls(cc,FindControl);

}

}

myC is a private property:
private Control myC;
 
Missed the point. This is done as with any other control that is just
ContentPlaceHolder1.FindControl("Label1").
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top