retrieve dynmatic control values

  • Thread starter Thread starter nic
  • Start date Start date
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
 
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
 
Back
Top