设为首页   加入最爱           最新更新:全方位英文文章资料库
 
资料坊搜索: 标题 全文     
ASP.NET中的HTML编码和URL编码
   首页>>YesizeCOM>>电脑技能坊>>HTML>>正文       
 
广告招租,e-mail:yesize@hotmail.com

广告招租,e-mail:yesize@hotmail.com

导 读: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>
上一篇:如何在HTML页面中使用js文件 下一篇:HTML 注释

版权说明:作品来源于网上,版权归作者所有,如果无意中侵犯了您的版权,请来信告知,本站将在3个工作日内删除。yesize@hotmail.com
  热门小游戏分类 
射击小游戏 连连看小游戏
台球小游戏 成人小游戏
CS小游戏 化妆小游戏
赛车小游戏 休闲小游戏
篮球小游戏 换装小游戏
儿童小游戏 牛牛小游戏
麻将小游戏 冒险小游戏
美媚小游戏 益智小游戏
体育小游戏  
Society Recreation & Sports
Travel & Leisure Communications
Vehicles Computers
Fashion Arts & Entertainment
Reference & Education Disease & Illness
Writing & Speaking Politics
Product Reviews Food & Beverage
Finance Internet Business
Self Improvement Home & Family
Health & Fitness Business
最新更新内容
警惕“公务员报考热”背
公务员考试不是丈母娘考
一名新公务员的自白:我
公务员考脑筋急转弯与挂
北努斗:2006行政能力测
大讨论:06行测BT题目大
过来人回忆:当年,我也
一家之言:公务员热折射
公务员考试申论要是有正
数十万大学生走进公务员
      粤ICP备05005424         Copyright ©2000 - 2004 Yesize.COM