Finding the values of Dynamic Controls in a Composite Control

Discussion in 'ASP .Net Building Controls' started by Bryan, Jun 12, 2006.

  1. Bryan

    Bryan Guest

    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
     
    Bryan, Jun 12, 2006
    #1
    1. Advertising

  2. 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

    "Bryan" <> ha scritto nel messaggio
    news:...
    > 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
    >
     
    Alessandro Zifiglio, Jun 13, 2006
    #2
    1. Advertising

  3. Bryan

    Bryan Guest

    Excellent! Thank you, Alessandro.

    - Bryan

    Alessandro Zifiglio wrote:
    > 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
     
    Bryan, Jun 14, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sleigh
    Replies:
    1
    Views:
    2,694
    sleigh
    Feb 12, 2004
  2. Harry
    Replies:
    2
    Views:
    663
    Harry
    Apr 16, 2004
  3. Ralf Müller

    composite control: how to assign initial values to child controls?

    Ralf Müller, Dec 10, 2004, in forum: ASP .Net Building Controls
    Replies:
    5
    Views:
    168
    Nicole Schenk
    Dec 15, 2004
  4. Chad
    Replies:
    0
    Views:
    225
  5. Mike

    Composite vs non composite Controls

    Mike, Mar 10, 2005, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    266
    Sundararajan
    Mar 11, 2005
Loading...

Share This Page