Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set the css class of a div using code behind [duplicate]

Tags:

c#

asp.net

vb.net

I understand that we can set the various style attributes from code behind using :

divControl.Style("height") = "200px"

But how to set it's class instead of declaring each of the styles from code?

like image 727
wotney Avatar asked Jun 15 '12 20:06

wotney


1 Answers

C#

divControl.Attributes["class"] = "myClass";

VB

divControl.Attributes("class") = "myClass"

You'll need to have a rule like this one on your css file

.myClass
{
   height:200px; 
   /*...more styles*/
}
like image 180
Claudio Redi Avatar answered Oct 17 '22 02:10

Claudio Redi