Re: Loop through controls on Page_Load event

Discussion in 'ASP .Net' started by Andy Gaskell, May 13, 2004.

  1. Andy Gaskell

    Andy Gaskell Guest

    You might want to change your For Each loop to this:

    For each oControl in Me.Controls(1).Controls
    if oControl.ID = "txtAcct" then
    'do some
    end if
    Next


    You also might want to look at the FindControl method.





    "Kent" <> wrote in message
    news:...
    > I'm trying to loop through the 6 server controls I have on my asp page

    during the Page_Load event. Why don't the controls show up in the Controls
    collection? I realize that the controls are not rendered at this point, but
    there must be a way to loop through them. Here the code I have tried. When
    I do a count on the controls collection it is 3 even though I have six.
    >
    > Private Sub Page_Load(...)
    > Dim oControl as Control
    >
    > For each oControl in Me.Controls
    > if oControl.ID = "txtAcct" then
    > 'do some
    > end if
    > Next
    > End Sub
    >
    > Thanks,
    > Kent
    >
    >
    >
     
    Andy Gaskell, May 13, 2004
    #1
    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. bminder
    Replies:
    1
    Views:
    2,183
    nfedin
    Feb 23, 2004
  2. Eliyahu Goldin

    Re: Loop through controls on Page_Load event

    Eliyahu Goldin, May 13, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    445
    Eliyahu Goldin
    May 13, 2004
  3. Scott Allen
    Replies:
    0
    Views:
    486
    Scott Allen
    May 14, 2004
  4. rockdale
    Replies:
    1
    Views:
    665
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Nov 16, 2006
  5. Isaac Won
    Replies:
    9
    Views:
    391
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page