Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change all text box visible properties on a page

Status
Not open for further replies.

bopritchard

Programmer
Jan 27, 2003
199
US
i want to be able to toggle the visibility property of all of the text boxes on my web page

and without literally naming each and every control...i want to walkthrough a collection and set them

how?

thanks
 
You could make an array or ArrayList containting all of the TextBoxes on your page and iterate through that:

Code:
TextBox[] textArray = new TextBox[5];

/* Code here putting TextBoxes into the array */

foreach(TextBox myBox in textArray)
{
    myBox.Visible = false;
}
 
or

TextBox temptxt = new TextBox();

for (int i =0; i < this.Controls.Count; i++)
{
if (this.Controls.GetType() == temptxt.GetType())
{
TextBox myTextBox = (TextBox) this.Controls;
//Make your changes here to myTextBox
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top