how could the child web user control ( .ascx ) get the value from parent ( .aspx ) ?

how could the child web user control ( .ascx ) get the value from parent ( .aspx ) ?
I have a hidden control in web form ( .aspx page ) I would like to get the value of this hidden control from a nested web user control ..
any help on it ?
Ameerh24Asked:
Who is Participating?
 
PHDConnect With a Mentor Commented:
You can use the findcontrol method of the page within the usercontrol :
in C# :
 HiddenField hf_page = (HiddenField)Page.FindControl("HiddenField1");
      hf_page.Value;

in vb :   Dim hf_page As HiddenField
        hf_page = Page.FindControl("Hiddenfield1")
0
 
renjurdevanConnect With a Mentor Commented:
place a public property in ascx !! for example "Property_In_ASCX "

in aspx page

Control obj_VMwareCtrl  ;
obj_VMwareCtrl = LoadControl("VMware_Ctrl.ascx") ;  
(VMware_Ctrl)obj_VMwareCtrl.Property_In_ASCX = 123;  // VMware_Ctrl be the class of ascx

this.Controls.Add(obj_VMwareCtrl) ;

Regards
Renju

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.