views:

105

answers:

3

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?

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
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
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
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
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