Override Css Class

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
 
P

Peter Bucher [MVP]

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
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top