Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I assign more than one "CssClass" to a control in asp.net

Tags:

css

asp.net

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

like image 537
ahmed Avatar asked Jan 31 '09 00:01

ahmed


People also ask

Can you assign more than one class to a div?

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.

Can you assign two classes to an element?

HTML elements can be assigned multiple classes by listing the classes in the class attribute, with a blank space to separate them.

Can you assign the same class to multiple HTML elements?

The HTML class attribute is used to specify a class for an HTML element. Multiple HTML elements can share the same class.

What is CssClass in asp net?

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" .


1 Answers

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>
like image 195
Larsenal Avatar answered Sep 18 '22 01:09

Larsenal