Results 1 to 2 of 2

Thread: Loop trough textboxes

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2002
    Location
    Helsingborg,Sweden
    Posts
    35

    Loop trough textboxes

    Hi!

    I have a form with 6 textboxes. How can i loop trough all textboxes. I have named them txtEmail1, txtEamil2 ect,ect.

    I have somewhere in my brain that i could use a for each textboxes, but i dont know.

    Can someone please help me!

    tyson

  2. #2
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Loop trough textboxes

    VB Code:
    1. For Each PageControl As System.Web.UI.Control In Page.Controls
    2.             If TypeOf PageControl Is System.Web.UI.WebControls.TextBox Then
    3.                 Dim CurrentTextBox As TextBox = CType(PageControl, TextBox)
    4.  
    5.                 'code here to do somethign with textbox
    6.  
    7.             End If
    8.         Next PageControl
    This is what I use, I use it to through through panels, and have just modified my code to get textboxes.

    Hope this helps.

    Woka

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width