Getting values entered into (dynamicly loaded control)

  • Thread starter Micha³ Januszczyk
  • Start date
M

Micha³ Januszczyk

I've dynamicly loaded user control (.ascx file) into my page via
Page.LoadControl() method. The control has been added to Controls collection
of some TableCell (named dynamicCtlPlaceholder). The control appears in the
desired location. The control allows to enter two strings: name and surname.

I would like to get data, that user entered into the control (two textboxes
inside the control) upon postback. how can I get it ?
When I iterate through the dynamicCtlPlaceholder's Controls property, there
is no my control. The runtime has not recreated it upon postback.

How can I get the values ?

Thanks for help
Michal Januszczyk
 
M

Micha³ Januszczyk

Mantas Miliukas said:
Assign ID for your control.
And do like this:

Page.FindControl(ID)

The problem lays more deep down than I thought.

I had not mentioned previously that the dynamicly loaded control is
constructed
each time it is loaded. Its partial controls are dynamically created, and so
the values
are lost. Besides that, the control was not loaded each time the page was
reloaded.

But, ok. Now the control is reloaded each time the page is posted back.
Additionally
I have added a "static" (not dynamically created) Control (also TextBox).
This Textbox
preserves its value, but the ones that are generated dynamically do not. Is
there any way
to make them behave the same as the "static" one control ?

Thanks
Micha³ Januszczyk
 
M

Micha³ Januszczyk

more details:

It seems that dynamically generated IDs for the controls caused that the
values have not been retained. The IDs were generated (and assigned to
controls) so as to allow dynamically created validators to watch the very
controls. Validators unfortunately cannot be told to watch specified object,
but it accepts only textual ID of the control (ControlToValidate property)

Regards,
Micha³ Januszczyk
 
M

Mantas Miliukas

When are you performing the search?
Basically you can do it by overriding or attaching to "OnLoad" method.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top