asp.net Server.HtmlEncode和HtmlDecode

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">

<div>
<%--把文本原样输出--%>
<%=Server.HtmlEncode("<span style='color:rebeccapurple;'>测试</span>") %>
<%-- HTML正常输出--%>
<%=Server.HtmlDecode("<span style='color:rebeccapurple;'>测试2</span>") %>
</div>
</form>
</body>
</html>

posted @ 2015-11-09 22:55  caichao  阅读(619)  评论(0编辑  收藏  举报