0

Hi Everyone,

Thanks for viewing this post.

I have placed the code below in the MASTERPAGE.master.cs

Label user = (Label)Master.FindControl("lblHidden123");

The control named lblHidden123 is in one of the Child page that refer to MASTERPAGE.master.. This control lblHidden123 is a normal label field, visible true.

When i try to access it in the MASTERPAGE.master.cs with the code above, it is always returning me NULL. Is there anything wrong with the code?

Please kindly advice me and do let me know if my post is unclear.
Thanks!

2
Contributors
2
Replies
13
Views
2 Years
Discussion Span
Last Post by strRusty_gal
1

The code you are using would be conceptually done from the "child page" (for the lack of a better term, but so you understand) trying to access a control in the master page.

You want the reverse, so from the master page, you should be able to access the controls within the pages linked to the master via the contentplaceholder controls they are in. For example in your master code behind...

Label lbl = (Label)ContentPlaceHolder1.FindControl("lblHidden123");
// do something with lbl.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.