Friday, March 16, 2012

make all controls visible=false

Is there a way to set all controls to visible=false, other than manually hard coding each individual control to visible = false?You could put the controls in a Panel and set the Panel's visibility to false.
yea thats the way I usually do it, except this piece of code was not written by me and the controls are jumbled everywhere in no logical order. looks like I'll just do it the old fashion way.
I believe you're looking for something such as:

protected void Page_Load(object sender, EventArgs e)
{
foreach (Control thisControl in this.form1.Controls)
{
//Do something
}
}

This will loop through all the controls in form1 on the page.
Yup! the easiest way to go is using the Panels.

or else you can use a recursive loop to make all the controls invisible.

0 comments:

Post a Comment