Pass a form value from a user control to parent control - Event Order issues

A

ab_j

I have a user control that contains a dropdown which I want to use as a
menu on multiple .aspx pages. Basically, all I am trying to do is pass
the selected value of the dropdown in the user control to the main
..aspx page.

In an attempt to make it more clear on what I am talking about, here is
the order of events in page life cycle (from
http://www.dotnetspider.com/technology/KBPages/789.aspx)
..ascx - OnInit()
..ascx - Page_Init()
..aspx - OnInit()
..aspx - Page_Init()
..aspx - Page_Load()
..ascx - Page_Load()
..ascx or .aspx control events
..aspx - Page_PreRender()
..ascx - Page_PreRender()
..ascx - Page_Unload()
..aspx - Page_Unload()

The problem that I am having is that I can't get the value of the
currently selected option of the dropdown until the ".ascx -
Page_Load()" event, but that doesn't occur until after the ".aspx
- Page_Load()" which is too late.

I experimented with trying to get the value by overriding the
LoadViewState event of the user control(which occurs between
Page_Init() and and Page_Load() but then everything seems to be one
page behind.

So here is my question: How can I pass a form value from a user
control to its parent control when the user control's events are
processed AFTER its parent's events?

It seems to me my only options are:
1) Find a way to get the value before the Page_Onload() event
2) Do all of the code work on the main .aspx page in the
Page_PreRender() phase (is there anything wrong with this?)

I come from a regular asp (vbscript) background so I know that I
sometimes go about these things all wrong. What is the best solution?

BTW, I am referencing a public integer from the user control from the
main page with the following line: MyMenu =
DirectCast(FindControl("user_menu1"), user_menu) Is there a better way?
Any help would be appreciated!

-Aeron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top