Simple thing, well, I think it is.
I need to Add a class to an element within an asp:repeater under certain conditions, using VB.
So, I can do
ITEMID.Attributes.Add("class", "classToAdd")
But this removes the existing classes and therefore screws up my CSS.
ITEMID.Attributes("class") = "classToAdd"
Seems to do the same thing.
How do I add a class to an element, whilst preserving it’s existing class values?
Use
+=to add additional class, and make sure you leave a space before or else it will appear ascurrentClassclassToAdd, where current class iscurrentClass:This is the same as doing:
Therefore: