looping through controls

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello, i got many asp.net controls and i want to put the same values into all
of the contorls. is there a better coding habit to allow me to loop through
all these contorls with different id to have the same attribute. e.g css
class name or height or enable/disable it. thanks
 
sure,

you can do something like this :

foreach(Control ChildControl in pnlDocument.Controls[0].Controls) //get
child controls of a objcet , this can be page itself
{
if (ChildControl.GetType()==typeof(Controls.ErsinContent)) // check the
type of the object if this is one of your objects
{
Controls.ErsinContent
Content=(ErsinPortal.Controls.ErsinContent)ChildControl; //cast object as
your object
Content.Content=ContentRow.Content; //change properties
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top