I am setting 2 css class in the code behind in ASP.NET
I could either do:
txtBox.Attributes.Add("class", "myClass1");
txtBox.Attributes.Add("class", "myClass2");
it's always apply one Class .. How can i add thw two classes ?
The Add method is actually a Put, since it replaces the value behing the key "class". In HTML/css you can have several classes by separating with a space.
txtBox.Attributes.Add("class", "myClass1 myClass2");
txtBox.CssClass = "myClass1 myClass2". In this way you can also add/remove classes later: txtBox.CssClass += " myClass3" / txtBox.CssClass.Replace("myClass1", "")You can also try
txtBox.CssClass = "myClass1 myClass2";