It's easy to set CssClass
in the code-behind, but this runs the risk of overwriting existing classes.
I need to set certain elements to ReadOnly = true;
and I'd like to apply a style as a visual cue that the item cannot be altered...easy enough:
.CssClass += " ReadOnlyStyle";
But at times I will also need to change the same element to ReadOnly = false;
which means that I will need to remove the CSS class that I set without removing any other styles that I might have assigned.
What's the best way to do this?
This version checks to make sure the given class isn't already added before adding it.