Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何"Replace & with &"在 aspx 页面的标签或文本框中显示文本?当我放入Text="Replace & with &"aspx 页面时,我得到的输出是“用 & 替换 &”
"Replace & with &"
Text="Replace & with &"
使用HttpUtility.HtmlEncode("&");这始终有效,并且生成的代码更具可读性。
HttpUtility.HtmlEncode("&")
替换&为&:
&
&
Text = "Replace & with &";
您还可以使其适用于任何角色,而不仅仅是&:
string s = "<"; Text = HttpUtility.HtmlEncode("Replace " + s + " with " + HttpUtility.HtmlEncode(s));