Simple textbox question

jccorner

Centurion
Joined
Jan 31, 2004
Messages
144
I have twenty-five textboxes on an ASP.net web app.

Would anyone be familiar about how I would go about making them all invisible with a simple do loop??

For example, if the names were txtField1, txtField2, txtField3...
Code:
count = 0
i = 1
dowhile count < 25
      txtField & "i".visible = True
      i = i + 1
      count = count + 1
enddo

Greatly appreciate any assistance.
 
Each textbox has a property called "Tag" that is for user defined information. Maybe put a 1 for those textboxes you do want to be visable and a 0 in the ones you want to not be visable. then using the same code I suggested, modify it like this. Besure to to put a 1 in the tag of textboxes you do not wish to have hidden. I guess by default, nothing in the tag will be looked at as a 0.

Visual Basic:
Dim control As Control
        For Each control In Controls
            If TypeOf (control) Is TextBox And control.Tag = 0 Then
                control.Visible = False
            End If
        Next
 
Last edited:
jccorner said:
But what if I have other textboxes on the screen that I don't want to touch.
In that case you'd need some way of identifying which ones your interested in. You could use their name, if they were all named similarly. For example:

Visual Basic:
If control.Name.StartsWith("txtTheseOnes") then control.Hide

Or you could use the Tag property to distinguish them.
 
Back
Top