Get MasterPage Hiddenfield Value From a User Class

Batuta picture Batuta · Feb 27, 2009 · Viewed 10.9k times · Source

Is there a way to get a value I am storing in a Master Page hidden field from a User Class which I created and placed in the App_Code folder of my ASP.Net 2.0 Application?

Some examples would preferably in VB.Net is highly appreciated.

Thanks.

To give further details, assume the following:

MasterPage.Master MasterPage.Master.vb

MyPage.aspx Mypage.aspx.vb

IN the app_code folder, add a new class, say TESTClass.

I have placed some logic in master page. MyPage.aspx uses the Masterpage.master as its master page. In the master page, the logic which I did stores a value into a hidden field.

in my TestClass, how do I access the master page hidden field?

Please take note that TestClass is NOT a user control but a user defined class, which contains some Business-Specific logic which is accessed by myPage.aspx.vb.

I tried ScarletGarden's suggestion but it did not seem to get the Masterpage Hiddenfield which I need to get the value.

Answer

Jared picture Jared · Feb 27, 2009

Would something like this work?

((HiddenField)this.Page.Master.FindControl("[hidden control id]")).Text