Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > dynamic loading - click event won't fire

Reply
Thread Tools

dynamic loading - click event won't fire

 
 
CalSun
Guest
Posts: n/a
 
      07-08-2005
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


 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      07-12-2005
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


 
Reply With Quote
 
 
 
 
CalSun
Guest
Posts: n/a
 
      07-20-2005
Thanks a lot


"Teemu Keiski" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When user press F5 after a button click event, the click event fires again! Max2006 ASP .Net 2 09-19-2007 05:37 AM
How to fire both event button click and textchanged when button is click and text is changed Amy ASP .Net 0 06-01-2006 02:33 PM
Wire up a click event within another click event doesn't work... Chu ASP .Net 2 04-10-2006 10:43 PM
image button click event fires before click event of button Purvi T ASP .Net 0 10-19-2004 06:19 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net 2 05-25-2004 11:45 PM



Advertisments