views:

58

answers:

2

Hi. Is it possible to get all controls from a ChildPage from the MasterPage the child is nested in?

I need all the controls within my form tag, but when i use a MasterPage i cant see the controls from the ChildPage, only the ones in the MasterPage.

Anyone with a good solution on this one? :)

+2  A: 

Suppose you have a Label control as [Label1] on the child page.

So to access that child page control from the master page, i would use

Label lbl = (Label)this.ContentPlaceHolder1.FindControl("Label1");

lbl.Text = "I got you";


So to get all the controls simply do this:

ContentPlaceHolder1.Controls

Issa Qandil
+1  A: 

Here's a great article on some more advanced master page topics. I believe your situation is covered.

http://odetocode.com/articles/450.aspx

ScottE