Finding the values of Dynamic Controls in a Composite Control

B

Bryan

Hi Everyone,

I've created a Custom Composite Control that creates a number of
children -- Hidden Input Fields, to be exact. Because my control
implements INamingContainer, I can't guaruntee what the names or IDs of
these children will be after the control is rendered.

So, after a post, how do I get to these controls?

- FindControl?

- Loop through all controls looking at the IDs?

- Loop through Request.Form?

- Something else?

Thanks in advance for the suggestions!

- Bryan
 
A

Alessandro Zifiglio

hi Bryan, just provide an explicit id to your child controls. True, a unique
namespace will be appended to the id value at runtime when the control
renders in the page. This however will not effect you from finding the
control in question in code, after a postback. All you need to do is use the
findcontrol method supplying the id you provided earlier. Since you are
using findcontrol in the namingcontainer, you are not expected to provide
the clientID.
Alessandro Zifiglio
 

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,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top