jccorner Posted March 31, 2004 Posted March 31, 2004 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. Quote Applying computer technology is simply finding the right wrench to pound in the correct screw
Rick_Fla Posted March 31, 2004 Posted March 31, 2004 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 Quote "Nobody knows what I do until I stop doing it."
jccorner Posted April 2, 2004 Author Posted April 2, 2004 But what if I have other textboxes on the screen that I don't want to touch. Quote Applying computer technology is simply finding the right wrench to pound in the correct screw
Rick_Fla Posted April 2, 2004 Posted April 2, 2004 (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 April 2, 2004 by Rick_Fla Quote "Nobody knows what I do until I stop doing it."
TechnoTone Posted April 2, 2004 Posted April 2, 2004 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. Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.