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? :)
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
Here's a great article on some more advanced master page topics. I believe your situation is covered.
http://odetocode.com/articles/450.aspx
精彩评论