dynamic loading - click event won't fire

Discussion in 'ASP .Net Building Controls' started by CalSun, Jul 8, 2005.

  1. CalSun

    CalSun Guest

    Hi all,
    I have a login control. As I add this control at design time, the control
    login_button_Click event got called.
    However, it doesn't do the same as I add this control dynamically.

    Here is how I load the ctrl dynamically

    Dim loginctrl As Control

    loginctrl = LoadControl("login.ascx")

    BodyPage.Controls.Add(loginctrl)

    (bodypage is the id of a placeholder)

    thank you all for helping.

    --calsun
    CalSun, Jul 8, 2005
    #1
    1. Advertising

  2. CalSun

    Teemu Keiski Guest

    Hi,

    do you do the adding in Page_Load? That's where it should happen for dynamic
    controls. See following page/control lifecycle for an explanation.

    1. Instantiate
    2. Initialize
    3. TrackViewState
    4. LoadViewState (postback)
    5. Load postback data (postback, IPostBackDatahandler.LoadPostdata)
    6. Load
    7. Load postback data for dynamical controls added on Page_Load (postback)
    8. Raise Changed Events (postback,
    IPostBackDatahandler.RaisePostDataChanged)
    9. Raise postback event (postback, IPostBackEventHandler.RaisePostBackEvent)
    10.PreRender
    11. SaveViewState
    12. Render
    13. Unload
    14. Dispose

    As you see, raising events happens right after Page_Load and it happens by
    the Page (so control playing catchup in dynamic control scenario won't help
    with it) so controls raising events must be in Controls collection at the
    Page_Load at the latest.

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke
    Teemu Keiski, Jul 12, 2005
    #2
    1. Advertising

  3. CalSun

    CalSun Guest

    Thanks a lot


    "Teemu Keiski" <> wrote in message
    news:...
    > Hi,
    >
    > do you do the adding in Page_Load? That's where it should happen for
    > dynamic controls. See following page/control lifecycle for an explanation.
    >
    > 1. Instantiate
    > 2. Initialize
    > 3. TrackViewState
    > 4. LoadViewState (postback)
    > 5. Load postback data (postback, IPostBackDatahandler.LoadPostdata)
    > 6. Load
    > 7. Load postback data for dynamical controls added on Page_Load (postback)
    > 8. Raise Changed Events (postback,
    > IPostBackDatahandler.RaisePostDataChanged)
    > 9. Raise postback event (postback,
    > IPostBackEventHandler.RaisePostBackEvent)
    > 10.PreRender
    > 11. SaveViewState
    > 12. Render
    > 13. Unload
    > 14. Dispose
    >
    > As you see, raising events happens right after Page_Load and it happens by
    > the Page (so control playing catchup in dynamic control scenario won't
    > help with it) so controls raising events must be in Controls collection at
    > the Page_Load at the latest.
    >
    > --
    > Teemu Keiski
    > ASP.NET MVP, AspInsider
    > Finland, EU
    > http://blogs.aspadvice.com/joteke
    >
    CalSun, Jul 20, 2005
    #3
    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. Chad
    Replies:
    4
    Views:
    8,323
  2. Amy
    Replies:
    0
    Views:
    974
  3. Mark Sisson

    UserControl click event won't fire

    Mark Sisson, Dec 2, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    117
    Thijs
    Dec 2, 2003
  4. Mark Sisson

    UserControl click event won't fire

    Mark Sisson, Dec 2, 2003, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    371
    Chris Thayer
    Dec 10, 2003
  5. Mark Sisson

    UserControl click event won't fire

    Mark Sisson, Dec 2, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    119
    Mark Sisson
    Dec 2, 2003
Loading...

Share This Page