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

Margins inside flexBox 2
Custom Control CssClass 0
Simple Javascript Inheritance Problem 0
Interfering CSS 1
CSS pseudo-class for after-input 4
Fire Event 1
Problems with css menu options 2
Event 2

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top