Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Must we use FindControl?

 
Thread Tools Search this Thread
Old 05-22-2008, 04:43 PM   #1
Default Must we use FindControl?


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.
  Reply With Quote
Old 05-22-2008, 05:19 PM   #2
bruce barker
 
Posts: n/a
Default RE: Must we use FindControl?
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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
C# .Net - Desperately need help with a ddl in a gridview in a usercontrol Apolta Software 0 06-09-2009 03:40 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46