Today, the contents of the database inside the output to the interface, encountered a problem. The content of the article does not have all the book out, in a place was staged, tangled for a long time, and then found the problem.
The problem arises in : " <meta charset=" utf-8″> "
In the Database Article table in the article has "<meta charset=" utf-8″> "this thing, and then query out to the server." The result of the query is no problem.
But I use Response.Write (item. Content); Item. Content is the article's table-of-contents field.
Output to the interface, in the encounter this thing "<meta charset=" utf-8″> "is truncated, the content will not be displayed.
Workaround?
1 (not recommended), is to put this content in <xmp></xmp>,//<pre></pre> and the pre-similar, but it does not parse [email protected]#$%^&* ( ) +=-[]\ ';,./{}| ": <>? These special characters
Want to display a piece of HTML code on a Web page, such as
<div style= "width:300px;height:200px;border:1px dashed Red" ></div>
I'm going to show this code instead of a div.
Several methods:
1) Encode this section of string
2) Call the Httputility.htmlencoder or Server.HTMLEncode method to process the string you want to output and then output it.
Response.Write (Server.HTMLEncode (list. First (). Content));
3) Very simple, directly can be placed in a <TEXTAREA> , the code is as follows:
<title>
Display HTML code
</title>
<body>
<textarea rows=6 cols=60>
<div style= "width:300px;height:200px;border:1px dashed Red" ></div>
</TEXTAREA>
</body>
The easiest way to put it in <textarea> is to use Httputility.htmlencode ().
If you think of the following display will be more time, you can use the third-party control to do.
<div style= "width:300px;height:200px;border:1px dashed Red" ></div>
4) There is also a super simple way to do this:
<xmp>
<div style= "width:300px;height:200px;border:1px dashed Red" ></div>
</xmp>
5) Put <textarea></textrea> suggestion also HTMLEncode () a bit.
or simply HTMLEncode () and put it in the page.
Reference: http://blog.sina.com.cn/s/blog_4ad042e50100dyx2.html