Must we use FindControl?

Discussion in 'ASP .Net' started by Jordan S., May 22, 2008.

  1. Jordan S.

    Jordan S. Guest

    Is FindControl() really the *only* way to later get a reference to controls
    that are dynamically added to a page?

    I am currently using ParseControl to insert a bunch of controls into a
    WebForm (which is itself dynamically inserted into the page).

    In subsequent code I do in fact know the ID of one of the controls added
    earlier via ParseControl. I would like to get a reference to that control
    via it's ID (perhaps qualified by it's naming container) and not have to use
    FindControl. But from all the googling I have done, it appears that my only
    alternative is to use FindControl - which is expensive and, IMHO unnecessary
    given that I already know the naming container in which the control exists.

    Do I have any alternatives to FindControl() ?

    Thanks.
    Jordan S., May 22, 2008
    #1
    1. Advertising

  2. Jordan S.

    bruce barker Guest

    no. you could save a reference to the control when you create it. if you
    don't do this then findcontrol is you only option. it just loops thru the
    naming container controls collection looking for a control with the specified
    id.

    -- bruce (sqlwork.com)


    "Jordan S." wrote:

    > Is FindControl() really the *only* way to later get a reference to controls
    > that are dynamically added to a page?
    >
    > I am currently using ParseControl to insert a bunch of controls into a
    > WebForm (which is itself dynamically inserted into the page).
    >
    > In subsequent code I do in fact know the ID of one of the controls added
    > earlier via ParseControl. I would like to get a reference to that control
    > via it's ID (perhaps qualified by it's naming container) and not have to use
    > FindControl. But from all the googling I have done, it appears that my only
    > alternative is to use FindControl - which is expensive and, IMHO unnecessary
    > given that I already know the naming container in which the control exists.
    >
    > Do I have any alternatives to FindControl() ?
    >
    > Thanks.
    >
    >
    >
    >
    bruce barker, May 22, 2008
    #2
    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. Sid
    Replies:
    4
    Views:
    572
  2. ad

    When need to use FindControl

    ad, Apr 28, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    434
    Karl Seguin
    Apr 28, 2005
  3. sck10
    Replies:
    6
    Views:
    19,801
    UdayGaikwad
    Oct 24, 2011
  4. NeoGeoSNK
    Replies:
    25
    Views:
    903
    NeoGeoSNK
    Nov 24, 2006
  5. Matt
    Replies:
    1
    Views:
    140
    Brynn
    Jan 18, 2004
Loading...

Share This Page