Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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...

count = 0
i = 1
dowhile count < 25
     txtField & "i".visible = True
     i = i + 1
     count = count + 1
enddo  

 

Greatly appreciate any assistance.

Posted

See if this helps any;

 

Dim control As Control
       For Each control In Controls
           If TypeOf (control) Is TextBox Then
               control.Visible = False
           End If

       Next

"Nobody knows what I do until I stop doing it."
Posted (edited)

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.

 

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

Edited by Rick_Fla
"Nobody knows what I do until I stop doing it."
Posted
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:

 

If control.Name.StartsWith("txtTheseOnes") then control.Hide

 

Or you could use the Tag property to distinguish them.

TT

(*_*)

 

There are 10 types of people in this world;

those that understand binary and those that don't.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...