Is there an inbuilt ASP.Net or MVC3 function that generates a valid CSS class given a string. Tagbuilder seems to have one AddCssClass. However just wondering if there is anything else that takes a string and converts it to valid CSS Class name by converting invalid characters to valid ones?
As an example say I have a string "Test. Bad Class Name"
I was wondering if there was a helper function to convert this to "Test__Bad Class_Name" or some such thing.
MVC doesn't seem to generate bad IDs etc so I just wondered if it had something that did this so I was being consistent. I just thought it would be a common requirement.
TagBuilder.AddCssClassgenerates a valid CSS name? You could throw just any crap at it and it will accept it :-) It's your responsibility not to throw crap at it. AFAIK there's no built-in method for this..test { color: Red }), or you just want a way to assign a class name (e.g. test) to a DOM element in your code (code-behind or view)? I'm not sure I totally understand what you want.