A question of (web)control and CssClass

K

kurt sune

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
 
P

Paul Henderson

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
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top