• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 836
  • Last Modified:

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 ?
0
Ameerh24
Asked:
Ameerh24
2 Solutions
 
PHDCommented:
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
 
renjurdevanCommented:
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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now