Override Css Class

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I have two custom controls Parent and Child, both inherit from
Composite Control. Child controls are added to parent.

Parent has a property named ChildControlCssClass.

I want ChildControlCssClass to be applied to all Child controls added
to Parent.

However, if I define the CssClass of a Child control then this would
be the one applied and not the ChildControlCssClass defined in its
parent.

What is the right way to do this?

Thanks,

Miguel
 
Hi Miguel
I have two custom controls Parent and Child, both inherit from
Composite Control. Child controls are added to parent.

Parent has a property named ChildControlCssClass.

I want ChildControlCssClass to be applied to all Child controls added
to Parent.

However, if I define the CssClass of a Child control then this would
be the one applied and not the ChildControlCssClass defined in its
parent.

What is the right way to do this?
A way would be to override the .Add method of ControlCollection.
But i would prefer to iterate in a time where all child controls added,
througt this collection, try cast to the base class (WebControl) and
set the property manually.

This is in my case, the better way.

--
Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET
http://www.peterbucher.ch/ - Meine Persönliche Seite
 
Back
Top