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

Discussion in 'ASP .Net' started by ab_j@flyingrobot.com, Oct 29, 2004.

  1. Guest

    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
     
    , Oct 29, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tom
    Replies:
    4
    Views:
    9,869
    S. Justin Gengo
    Nov 13, 2003
  2. Antonio
    Replies:
    4
    Views:
    623
    Antonio
    Jul 21, 2005
  3. Tillman

    Make parent control event call child control event

    Tillman, May 21, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    305
    Tillman
    May 21, 2004
  4. Noel Dolan
    Replies:
    0
    Views:
    236
    Noel Dolan
    Jul 18, 2004
  5. Replies:
    0
    Views:
    141
Loading...

Share This Page