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.
I know this pattern is overly zealous and replaces characters it shouldn’t, like numbers, but it will give you a one-way function for generating valid css class names.