且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将字符串转换为HTML安全字符串

更新时间:2022-02-20 22:38:20

您可以使用相同的类 HttpUtility 您可以使用javascript,但对于 html ,可以使用示例:

You can use the same class HttpUtility you have use to javascript, but, for html, for sample:

bldr.AppendFormat("<a>{0}</a>\n", HttpUtility.HtmlEncode(user.Company));

还有使用 HttpUtility.HtmlDecode(string)