Passing value from parent.aspx to webusercontrol.ascx that is inside the parent.aspx

d3nn1s
d3nn1s used Ask the Experts™
on
layout scenario
 <parent.aspx>
      -<Update Panel>
         -<textbox search>
            -on textchanged bind results to datagrid result
         -<datagrid search result>
            -on row click pass the ID to ascx then show data
      -</Update Panel>
      - <Update Panel>
               -<Tab Panel1>
                         *ascx requires an ID to show the data
                      -<Webusercontrol1.ascx />
               -</Tab Panel1>
               -<Tab Panel1>
                         *ascx requires an ID to show the data
                      -<Webusercontrol2.ascx />
               -</Tab Panel1>
       -</Update Panel>
<parent.aspx>

It seems the page cycle when the datagid selected index changed is only fired after the webusercontrols are loaded so i need to click it again.

it will work when i try load the ascx on runtime but the buttons are not working inside the acsx and also ascx disappears when i click on the parent page.

Is there a way that i can prioritized the parent.aspx to fire the seletected index changed first before the ascx fires it page load?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Edgard YamashitaSystems Analyst

Commented:
it will be better to go for option 2 i think:
"it will work when i try load the ascx on runtime but the buttons are not working inside the acsx and also ascx disappears when i click on the parent page."

the reason the ascx disappears is because that when you create controls at runtime you need to recreate then at every postback..

so if when you tried first, were you creating the control in a

if(!IsPostBack)
{
}
?

if so, create then outsite the block and try again

Author

Commented:
I did that before if the event is from parent.aspx but if try to click the buttons of ascx the events is not firing at all it will just disappear on the parent.aspx
Vikram Singh SainiSoftware Engineer cum AD Developer

Commented:
Refer to link:

http://niitdeveloper.blogspot.com/2010/10/nested-user-controls-and-events.html

And please let us know the scenario exactly. Are you creating user control at runtime and then adding it to .aspx page. Or something else.

Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Author

Commented:
I tried both but just like i said if try putting it on aspx the only problem is the passing of values for the ascx when i fire an event from aspx page the value is transfered after the ascx page load finish so the data load for ascx is empty. On the other method by loading on memory the only problem is the controls inside ascx is not firing.

I will try the link you posted i think that will help.
Commented:
to make it simple - on aspx datagrid "datagrid_SelectedIndexChanged" event pass the id then load the ascx

the ascx contains labels, datagrids, buttons
the ascx 's datagrid has "PageIndexChanging", "SelectedIndexChanged" events
the ascx 's buttons has "button_Click" event

Question is How can i also register the ascx events in memory?
Vikram Singh SainiSoftware Engineer cum AD Developer

Commented:
I would like to know solution too.

Regards,
VSS

Author

Commented:
i solved the problem myself.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial