Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a hidden control in a aspx page . I want to get its value in the user control page that binds the aspx page...Please help
Posted
Updated 14-Mar-14 3:47am
v2

your can access your user control hidden filed value by following ways

C#
var hdn = YourUserControl.FindControl("yourhiddencontrolid");



Or you can also create a properties in your user control which is returning your hidden filed value like this...


C#
public string HiddenFiledValue { 
    get{
        return myHiddenFiled.Value;
    }
    set{
        myHiddenFiled.Value = value;
    }
}


and use that property in your parent page like this...
C#
yourusercontrol.HiddenFiledValue 
 
Share this answer
 
Comments
Arjun Menon U.K 17-Mar-14 0:47am    
Hi Tejas,
since the hidden control in Master page(ASPX) is it possible to get the value of that control in child page(ASCX) ?????
i gave like this
HiddenControl hdn=(HiddenControl)Page.FindControl("hdnText");

This is the control in aspx page
<asp:HiddenField ID="hdnText" runat="server" Value="0" />

But it returns null
Arjun Menon U.K 17-Mar-14 0:51am    
When i inspect the Page , its showing the aspx page name but control name is not there in the collection class... y is that so?
Arjun Menon U.K 17-Mar-14 7:26am    
can i use this.context. something to get the value?
Have you not tried anything like this,
HiddenField Info = this.Page.FindControl("MyHiddenField");

-KR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900