I am creating some textboxes dynamically and I try to get their values when I click a button, but they are gone. I create the text boxes (declaration, initialization, adding them to the place holder) in another click button event. What shall I change to be able to read their values?
views:
105answers:
3
A:
If you will create the controls on the Init stage (eg: Init event) on every request (eg, both postback and non-postback) then they will be available and will preserve their state.
Dmytrii Nagirniak
2009-08-20 09:25:55
what do u mean by create? which of those you mean?(declaration, initialization, adding them to the place holder)or all of them?
Ahmad Farid
2009-08-20 09:35:30
In order to preserver the state of the dynamic controls they should be created (instanciated and added to the page/placeholder) in Init event.
Dmytrii Nagirniak
2009-08-21 06:45:33
A:
There could be several reasons one of Them being your control initialization being executed prior to the event handler. This will be the case if you on post back initialize the controls in page_load. The click event handler is executed after page_load is run
Rune FS
2009-08-20 09:33:06
A:
How about getting the values using a simple Request.Form
. That should work regardless of how you add the controls. Post some source, so we can see what's going on. :)
Jakob Gade
2009-08-20 09:55:38