hello, i got many asp.net controls and i want to put the same values into al
l
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. thankssure,
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
}
}
}
"Asha" <Asha@.discussions.microsoft.com> wrote in message
news:426FEEAC-31E3-49AA-BF0F-B30D7A191452@.microsoft.com...
> 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
Here's an example that shows you how to loop through your controls and set
a property:
http://aspalliance.com/642
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Asha" <Asha@.discussions.microsoft.com> wrote in message
news:426FEEAC-31E3-49AA-BF0F-B30D7A191452@.microsoft.com...
> 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
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment