Override Css Class

Discussion in 'ASP .Net' started by shapper, Feb 24, 2008.

  1. shapper

    shapper Guest

    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
     
    shapper, Feb 24, 2008
    #1
    1. Advertising

  2. 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
     
    Peter Bucher [MVP], Feb 24, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Paasch

    CSS override trouble

    Andreas Paasch, Jul 10, 2003, in forum: HTML
    Replies:
    3
    Views:
    8,454
    PeterMcC
    Jul 10, 2003
  2. Jibba Jabba

    Can't override CSS class!!!

    Jibba Jabba, Feb 14, 2004, in forum: HTML
    Replies:
    11
    Views:
    37,154
    brandondrury
    Sep 30, 2007
  3. Woodmon
    Replies:
    20
    Views:
    16,873
    Toby Inkster
    Oct 22, 2005
  4. Nocturnal
    Replies:
    3
    Views:
    645
    Toby Inkster
    Jul 7, 2006
  5. Jer A
    Replies:
    2
    Views:
    186
    Dan Zwell
    May 24, 2007
Loading...

Share This Page