Can I assign more than one "CssClass" to a control in asp.net?How to do this?
Absolutely, divs can have more than one class and with some Bootstrap components you'll often need to have multiple classes for them to function as you want them to. Applying multiple classes of course is possible outside of bootstrap as well. All you have to do is separate each class with a space.
HTML elements can be assigned multiple classes by listing the classes in the class attribute, with a blank space to separate them.
The HTML class attribute is used to specify a class for an HTML element. Multiple HTML elements can share the same class.
ASP.Net CssClass is an abstract wrapper around the css "class" specifier. Essentially, for most intents and purposes, they are the same thing. When you set the CssClass property to some string like "someclass", the html that the WebControl will render will be class = "someclass" .
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With