adding server controls at the client at run time

Z

z f

hi, tough one? for me it is currently.

i have a user control that contains other controls like text boxes.

in the client i need to dynamically add the user control using DHTML.
i achive this by having the control hidden and grabbing it's innerHTML to a
new container in the HTML.
i also change controls ID suffix in order to be able to track added controls
like in old HTML.

for example txt_name_x_ becomes txt_name_1_.

now i need to instanciate the container control in the server after submit.

can this be done? without me having to get all the HTML submited internal
contained inputs of the control.

TIA!
 
S

S. Justin Gengo [MCP]

ZF,

I'm not positive what you're looking for based on your post, but I have a
sample of reloading dynamic controls in order to access their values that
may help you to see. It's at:
http://www.aboutfortunate.com?page=codelibrary. Just search for dynamic
control and you'll see a few different samples. The one I think you'll be
most interested in is: "Reload dynamically created user controls in order to
use their viewstate".

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
Z

z f

in the sample you specified, you load the control, but the control gets its
"default" instance.
i need the control to "load" it's state from what is being submitted, and
being submited more than one instance.
so i need to differentiate the controls instances by their IDs.
is giving the newly loaded control the rqeuired ID will do the job?
i'm not sure.
the result should be something like is achived by a repeater that spawns
many instances of a control (in the <ItemTemplate>) to the client, and then
in the submit, even that it is not being binded again to the data, creates
the instances of the "spawned" control and creating them dynamically .

thanks
 
S

S. Justin Gengo [MCP]

zf,

Did you also check out the "Dynamically add text boxes (or any web control)
to a page" sample?

It's doing what you are asking about.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
Z

z f

ok thanks it looks good now.
the Controls.Add(ctl) line did the trick...

the problem i have now is getting the error
Control 'line_template_ctl1_x_' of type 'ComboBox' must be placed inside a
form tag with runat=server.
in the rendering stage.....
and i don't need the added controls to render at all.
it's just for the post processing.
after that all the page will be re-rendered
so i probably have to remove it unless you have other suggestion...
 

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,772
Messages
2,569,591
Members
45,100
Latest member
MelodeeFaj
Top