更新时间:2023-01-25 08:24:59
假设您使用的是 C#,您可以在页面上显示字符串时执行以下操作
Assuming you're using C# you can do the following when you display the string on the page
theStringYouWantToFormat.Replace(char.ConvertFromUtf32(13),"<br/>")
当您对从文本框中获取的值调用 Server.HtmlEncode
时,它会查看文本并对包含在该文本框中的任何 HTML 标记进行编码,例如 <script></script>
将被编码为 <script></script>
.
When you call Server.HtmlEncode
on the value you grab from a text box it'll look at the text and encode any HTML tags contained in that text box so for example <script></script>
would be encoded to <script></script>
.