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!

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.

Thank You! I got it!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.