Is there any object in the .NET开发者_如何转开发 framework that will sanitize a string so that it is safe to use as the "id" attribute value for an HTML tag?
System.Web.HttpUtility.HtmlEncode() is the closest thing I can think of.
Not that I am aware of. You could look at the specification for allowed characters and implement it. Note that this might me more difficult because you need to make sure that the identifier is unique within the HTML document.
精彩评论