欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!
您的位置:DIVCSS5首页 > HTML >

导 读:server.htmlencode 和 server.urlencode 是asp中很常用的函数,在asp.net中也有类似的函数:htmlencode 和 urlencode (注意大小写)以下用实例来进行介绍。 

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> 

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h57007.shtml

如对文章有任何疑问请提交到DIV CSS论坛,或有任何网页制作CSS问题立即到CSS论坛发贴求解 或 直接DIVCSS5网页顶部搜索遇到DIVCSS疑问。
CSS教程文章修订日期:2018-08-14 17:37 原创:DIVCSS5
本文www.divcss5.com DIVCSS5版权所有。