简体   繁体   中英

How to make Response.Write Display special character like “<”,“>”

I want to use Response.Write to display some text on the screen using ASP.NET I created a variable

String s = "There is some <hidden text> which is not visible";
Response.Write(s);

What I found is when the browser only display "There is some which is not visible" any text written in between symbols '<'......'>' is neglected by the browser.

How can I display entire text?

Please advice.

You can try this:

String s = @"There is some <hidden text> which is not visible";
Response.Write(s);

I'm not familiar with C# so this might not work, but you can escape the < and > by using html escape characters.

&#60; for <

&#62; for >

So maybe try...

String s = "There is some &#60;hidden text&#62; which is not visible";

使用HTML编码

Server.HtmlEncode("There is some <hidden text> which is not visible");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM