1

我想使用 Response.Write 使用 ASP.NET 在屏幕上显示一些文本我创建了一个变量

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

我发现当浏览器只显示“有一些不可见”时,任何写在符号 '<'......'>' 之间的文本都会被浏览器忽略。

如何显示整个文本?

请指教。

4

3 回答 3

2

你可以试试这个:

String s = @"There is some <hidden text> which is not visible";
Response.Write(s);
于 2014-03-09T12:46:40.417 回答
1

使用HTML 编码

Server.HtmlEncode("There is some <hidden text> which is not visible");
于 2014-03-09T13:15:58.113 回答
1

我不熟悉 C#,所以这可能行不通,但是您可以使用 html 转义字符来转义<and 。>

&#60;为了<

&#62;为了>

所以也许试试...

String s = "There is some &#60;hidden text&#62; which is not visible";
于 2014-03-09T12:43:36.367 回答