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?
Asked
Active
Viewed 416 times
0
-
have you got any example code to containing your problem? you should usually be able to access objects in your class from all events.. – Faizan S. Aug 20 '09 at 09:29
3 Answers
0
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
- 23,696
- 13
- 75
- 130
-
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 Aug 20 '09 at 09:35
-
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 Aug 21 '09 at 06:45
0
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
- 21,497
- 7
- 62
- 96
0
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
- 12,319
- 15
- 70
- 118