国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

ASP.NET中的HTML編碼和URL編碼

2024-07-10 13:05:27
字體:
供稿:網(wǎng)友
導(dǎo) 讀:server.htmlencode 和 server.urlencode 是asp中很常用的函數(shù),在asp.net中也有類似的函數(shù):htmlencode 和 urlencode (注意大小寫)以下用實(shí)例來進(jìn)行介紹。

server.htmlencode and server.urlencode are very common functions used
by asp developers. well, as you may have guessed, these two functions
have asp.net counterparts. htmlencode and urlencode (notice case) are
part of the system.web.httputility namespace.

here is the demo

urlencode.asp?test=1&test1=2
urlencode.asp%3ftest%3d1%26test1%3d2


this is a test & hopefully it works!
<h1>this is a test & hopefully it works!</h1>

**********************************
here is the code:
**********************************

<%@ page language="vb" %>
<%@ import namespace="system.web.httputility" %>
<html>
<head>
<title>htmlencode and urlencode the asp.net way</title>

<script language="vb" runat="server">
sub page_load(sender as object, e as eventargs)

''assign our test url to a variable, assign the variable to our
label control
dim strurltext as string = "urlencode.asp?test=1&test1=2"
strurl.text = strurltext

''encode the test url, assign it to a variable, assign the
variable to our label control
dim strurlencodetext as string = urlencode(strurltext)
strurlencode.text = strurlencodetext

''assign our test url to a variable, assign the variable to our
label control
dim strhtmltext as string = "<h1>this is a test & hopefully it
works!</h1>"
strhtml.text = strhtmltext

''encode the test html, assign it to a variable, assign the
variable to our label control
dim strhtmlencodetext as string = htmlencode(strhtmltext)
strhtmlencode.text = strhtmlencodetext

end sub
</script>
</head>
<body>
<asp:label id="strurl" forecolor="red" font-bold="true" runat=server/>
<p>
<asp:label id="strurlencode" forecolor="blue" font-bold="true" runat=server/>
<p>
<asp:label id="strhtml" forecolor="red" font-bold="true" runat=server/>
<p>
<asp:label id="strhtmlencode" forecolor="blue" font-bold="true" runat=server/>


</body>
</html>
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 凤山县| 金乡县| 新沂市| 兴仁县| 巨野县| 乌苏市| 建阳市| 富阳市| 苏尼特左旗| 蓬莱市| 蒙城县| 葵青区| 廉江市| 土默特左旗| 含山县| 凤庆县| 漳平市| 汉川市| 武胜县| 富平县| 固安县| 寻乌县| 五寨县| 广汉市| 佛教| 长阳| 江川县| 高州市| 乌兰浩特市| 宁陵县| 宁海县| 内江市| 邯郸市| 沾化县| 湟中县| 石台县| 翁牛特旗| 贵州省| 水富县| 仁布县| 自治县|