|
-
Jun 1st, 2004, 03:38 AM
#1
Thread Starter
Hyperactive Member
Dynamically-created-controls Event firing problem
Hey,
I create controls (Texboxes and Buttons) dynamically from DB in Page Load.
In every postback these controls are recreated which isn't needed for me.
So I put my controls creating code in "If Page.IsPostBack = False Then"
Now controls isn't created after I press button and postback is called, but now I lose event of that button and nothing happens.
I'm creating dynamic registration from and after button is clicked it should not recreate controls again, but write "Saved" etc.
How to fire event before button handler is lost?
-
Jun 1st, 2004, 11:43 AM
#2
PowerPoster
You are going to have to add the controls to the control tree on each load of the page, so instantiate and add your controls in the page init event handler.
-
Jun 1st, 2004, 11:46 AM
#3
I wonder how many charact
Well, the issue is really that the page needs to create those controls first. After that has been done and viewstate reloaded, it goes about handling any events that were raised.
It has to do this, otherwise you will never get the control to handle its own event if it hasn't been created.
-
Jun 1st, 2004, 11:47 AM
#4
Thread Starter
Hyperactive Member
I don't understood. Can you explain more dataily?
-
Jun 1st, 2004, 01:26 PM
#5
If you create controls in runtime, you will always have to create them on each load of the page. ViewState will always preserve their values (by default).
-
Jun 1st, 2004, 01:54 PM
#6
PowerPoster
Yes, what we all said is correct (I elected not to go into the gory details), and MS recommends doing this in the Page Init event handler, rather than the page load.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|