Runtme controls

G

Guest

have a Placeholder on whch a dynamically add controls at run tme, TextBox
DropDownList or CheckBox. I can populate these and providing I save the
placeholder n the SessionState etc. clear them etc.

However if I type into a dynamically added TextBox I can find no way of
getting at the text n code.

Any ideas?


Guy
 
M

Michael Nemtsev, MVP

Hello guy,

all controls are stored into page hierarch, nonwithstanding the fact how
you add them - statically or dynamically.

everything you need to do is just use FindControl method recursely on the
root objects to find your added control.

You can use the following codesnippets
- http://weblogs.asp.net/palermo4/archive/2007/04/13/recursive-findcontrol-t.aspx
- http://www.codekeep.net/snippets/0451a411-a6f8-4f78-9959-be8e9fa69393.aspx

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


g> have a Placeholder on whch a dynamically add controls at run tme,
g> TextBox DropDownList or CheckBox. I can populate these and providing
g> I save the placeholder n the SessionState etc. clear them etc.
g>
g> However if I type into a dynamically added TextBox I can find no way
g> of getting at the text n code.
g>
g> Any ideas?
g>
g> Guy
g>
 
P

Phil H

have a Placeholder on whch a dynamically add controls at run tme, TextBox
DropDownList or CheckBox. I can populate these and providing I save the
placeholder n the SessionState etc. clear them etc.

However if I type into a dynamically added TextBox I can find no way of
getting at the text n code.

Any ideas?

Guy

Hi Guy

I was faced with a similar situation. My solution was to give the
dynamically added controls a unique code in the ID field and store
them in Session state. On postback any changes to content are shown in
the Request.Header list (a dictionary list of events and control
states in the form (client_ID, value)) against the client_ID
(allocated by the server except that underscore characters are
replaced with $). Although client_ID is not under the programmers
control it will have a construction based on the ID property and will
have the special code embedded within it. You'll then need to use
string search functions to identify it in the list of controls stored
in Session state.

HTH
 

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,754
Messages
2,569,526
Members
44,997
Latest member
mileyka

Latest Threads

Top