467,890 Members | 1,663 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,890 developers. It's quick & easy.

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

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
..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!


Nov 18 '05 #1
  • viewed: 2155

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Jozef | last post: by
6 posts views Thread by drec | last post: by
6 posts views Thread by Goran Djuranovic | last post: by
4 posts views Thread by =?Utf-8?B?RWl0YW4=?= | last post: by
24 posts views Thread by =?Utf-8?B?U3dhcHB5?= | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.