asp.net学习笔记 HTMLEncode HTMLDecode URLEncode

HTMLEncode 方法对指定的字符串应用 HTML 编码。web

语法
Server.HTMLEncode( string )

参数
string 
指定要编码的字符串。 
示例
脚本浏览器

<%= Server.HTMLEncode("The paragraph tag: <P>") %> 

输出编码

The paragraph tag: &lt;P&gt;

注意 以上输出将被 Web 浏览器显示为code

The paragraph tag: <P>

若是查看一下源文件或以文本方式打开一个 Web 页,您就能够看到已编码的 HTML字符串

get

HTMLDecodestring

<%= Server.HTMLDecode("The paragraph tag: &lt;P&gt") %>it

输出: The paragraph tag: <P>date


URLEncode
URLEncode 方法将 URL 编码规则,包括转义字符,应用到指定的字符串。语法

语法
Server.URLEncode( string )

参数 
String 
指定要编码的字符串。 
示例
脚本

<%Response.Write(Server.URLEncode(http://www.updateweb.cn)) %>

输出

http%3A%2F%2Fwww%2Eupdateweb%2Ecom


原文http://hi.baidu.com/zwfec/item/80e3ba18bbfa920ce75c36af

相关文章
相关标签/搜索