开发者

.NET: Strongly-typed HTML "id" attribute

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜