retrieve dynmatic control values

N

nic

Hi,
I have an aspx page where I dynamically generate a number
of input controls. Upon submitting the form I need to re-
create the controls in order to retrieve their values. I
understand this, but I'm confused on how the newly
generated control and the previous control (before
postback) can share the same value (I'm glad it works but
I don't see how).

I also noticed I need to re-create the control in the
Page_Load event. If I create it in a later event (i.e. in
some method called by an onClick event) the form values
can not be retrieved.

When is the best time to recreate the control and how does
it work?

Thanks
 
G

Giorgio Parmeggiani

Hi
I have an aspx page where I dynamically generate a number
of input controls. Upon submitting the form I need to re-
create the controls in order to retrieve their values. I
understand this, but I'm confused on how the newly
generated control and the previous control (before
postback) can share the same value (I'm glad it works but
I don't see how).

The viewstate allows you to reload the values, however
, to every postback, you must always have recreated the same controls with
the same characteristics!
I also noticed I need to re-create the control in the
Page_Load event. If I create it in a later event (i.e. in
some method called by an onClick event) the form values
can not be retrieved.

When is the best time to recreate the control and how does
it work?

The best time to recreate the control is in the "Init" Event so the
ViewState is correctly loaded.

Ciao
Giorgio
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top