tags:

views:

503

answers:

4

Can I assign more than one "CssClass" to a control in asp.net?How to do this?

+9  A: 

To assign class "myClass1" and "myClass2" you simply say:

<asp:Label runat="server" CssClass="myClass1 myClass2" />

This is the same approach you'd use in normal HTML as in:

<div class="myClass1 myClass2"></div>
Larsenal
A: 

You can try the eqivalent of:

class="class1 class2"

So if it's a property just try throwing the classes with a space between them in there.

Sam
A: 

I imagine it's just like setting the class attribute in an XHTML element.

<p class="foo bar"></p>

<asp:Something CssClass="foo bar" runat="server" />
Matt Olenik
+2  A: 

If you wanted to add another class programmatically and don't know what classes have already been added

MyControl.CssClass += " newclass";
Khb