A question of (web)control and CssClass

Discussion in 'ASP .Net' started by kurt sune, Jan 17, 2006.

  1. kurt sune

    kurt sune Guest

    I am doing a custom control.
    It contains a label and a textbox and a button.
    The class inherits WebControl.

    Thus the control gets a property CssClass visible in the Properties window.

    Question 1. Is it possible to override this property AND give it another
    name, for example CssClassLabel?
    Is it ugly doing it as a CSV-property type "cssstyle1,cssstyle2,cssstyle3"?

    Since the control contains three controls I need to give CssClass-properties
    for each containde control.

    Question 2: Is this possible without resorting to prepertyname like
    CssClassLabel, CssClassButton etc.


    I have seen that Font has subnode in the properties window.

    Question 3: Is this possible in my own code? Type: CssClasses containg three
    subnodes: CssClassLabel, CssClassButton and so on


    /k
    kurt sune, Jan 17, 2006
    #1
    1. Advertising

  2. > Question 1. Is it possible to override this property AND give it another
    > name, for example CssClassLabel?


    No; you can override it by giving it the same name, or create another
    property with a different name, but not a property with a different
    name that acts as a new virtual implementation. If you need to override
    the base class functionality for calls from the base class (i.e. use it
    as a virtual method), you'll need to create a property (CssClass) with
    the same name using the 'override' modifier; you could then create
    another property (CssClassLabel) and make trivial accessors that just
    call your overridden version.

    I doubt you *really* want to do this, though, especially given your
    other questions. If the 'Label' style overrides the inherited CssClass,
    then what happens to the others?

    > Is it ugly doing it as a CSV-property type "cssstyle1,cssstyle2,cssstyle3"?


    Yes, somewhat. But it'll work...

    > Since the control contains three controls I need to give CssClass-properties
    > for each containde control.
    > Question 2: Is this possible without resorting to prepertyname like
    > CssClassLabel, CssClassButton etc.


    Well, it might be, but I'm not sure *why* you'd particularly want to.

    > I have seen that Font has subnode in the properties window.
    > Question 3: Is this possible in my own code? Type: CssClasses containg three
    >subnodes: CssClassLabel, CssClassButton and so on


    Not so far as I know
    Paul Henderson, Jan 17, 2006
    #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. Hardy Wang

    How to remove CssClass of a control?

    Hardy Wang, Nov 13, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    974
  2. Mervin Williams

    Setting CSSClass property of Label control?

    Mervin Williams, Apr 6, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    3,496
    Scott
    Apr 6, 2004
  3. =?Utf-8?B?bXN1aw==?=

    CssClass and HTML file field control

    =?Utf-8?B?bXN1aw==?=, Nov 25, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    646
    =?Utf-8?B?bXN1aw==?=
    Nov 30, 2004
  4. George Jordanov Ivanov

    Literal control doesn't have CssClass property?

    George Jordanov Ivanov, Mar 30, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    15,319
    WarNov
    Sep 13, 2006
  5. =?Utf-8?B?QVNQIERldmVsb3Blcg==?=

    CssClass property is ignored with wizard control (For some Users)

    =?Utf-8?B?QVNQIERldmVsb3Blcg==?=, Sep 19, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    587
    =?Utf-8?B?QVNQIERldmVsb3Blcg==?=
    Sep 19, 2006
Loading...

Share This Page