开发者

Get all controls from MasterPage ChildPage

开发者 https://www.devze.com 2022-12-09 15:18 出处:网络
Is it possible to get all controls from a ChildPage from the MasterPage the child 开发者_运维问答is nested in?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消