[英]How to make Response.Write Display special character like “<”,“>”
我想使用Response.Write使用ASP.NET在屏幕上显示一些文本,我创建了一个变量
String s = "There is some <hidden text> which is not visible";
Response.Write(s);
我发现的是,当浏览器仅显示“有些不可见”时,浏览器忽略了在符号“ <'......'>”之间写入的任何文本。
如何显示全文?
请指教。
您可以尝试以下方法:
String s = @"There is some <hidden text> which is not visible";
Response.Write(s);
我不熟悉C#,所以这可能行不通,但是您可以使用html转义字符来转义<
和>
。
<
对于<
>
对于>
所以也许尝试...
String s = "There is some <hidden text> which is not visible";
使用HTML编码
Server.HtmlEncode("There is some <hidden text> which is not visible");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.