ASP Encode/Decode Functions
http://www.aspnut.com/reference/encoding.asp
Server.URLEncode
Used for encoding data that will be passed via a querystring variable. A querystring variable is anything following the question mark (?) in the URL (location) field of your browser. You create querystring variables when you perform a redirect or build a hyperlink to another page on your site.
<a href="page2.asp?name=Joe+Schmoe">here</a>
<%
Response.Redirect "page2.asp?ID=3"
%>
In the example above, the hyperlink contains a variable named "name" which has a value of "Joe Schmoe" (the space is encoded as "+") In the Response.Redirect statement, we have a querystring variabled named "ID" with a value of 3. To perform a URL encode on a variable (for purposes of passing this variable to another page) use the following:
<a href="page2.asp?name=<%= Server.URLEncode(sName) %>">
here</a>
<%
Response.Redirect "page2.asp?ID=" &_
Server.URLEncode(nID)
%>
URLDecode
For some reason, Microsoft did not include a URL decode function with Active Server Pages. Most likely, this was because the decoding of querystring variables is done automatically for you when you access the querystring object:
<%= Request.QueryString("name") %>
For those of you who are desperately in need of this function:
' -----------------------------------------
' URL decode to retrieve the original value
Function URLDecode(sConvert)
Dim aSplit
Dim sOutput
Dim I
If IsNull(sConvert) Then
URLDecode = ""
Exit Function
End If
' convert all pluses to spaces
sOutput = REPLACE(sConvert, "+", " ")
' next convert %hexdigits to the character
aSplit = Split(sOutput, "%")
If IsArray(aSplit) Then
sOutput = aSplit(0)
For I = 0 to UBound(aSplit) - 1
sOutput = sOutput & _
Chr("&H" & Left(aSplit(i + 1), 2)) &_
Right(aSplit(i + 1), Len(aSplit(i + 1)) -
相关文档:
<%
'购物车类 类名:UserCart
'作者:gameing
'基本原理:此类用服务器Session变量保存商品数据,商品用一个数组表示.此类里面保存了三中商品价格.
'1、2008-11-25修改Function AddItem() by tommy 商品增加在最后
'2、2008-11-25修改by tommy 增加删除商品过程 Sub DelItem()
'3、2008-11-25转换一些数据类型才能� ......
Ajax.js
// AJAX类
function AJAXRequest() {
var xmlObj = false;
var CBfunc,ObjSelf;
ObjSelf=this;
try { xmlObj=new XMLHttpRequest; }
catch(e) {
try { xmlObj=new ActiveXObject("MSXML2.XMLHTTP"); }
catch(e2) {
try { xmlObj=new ActiveXObject("Microsoft.XMLHTTP"); }
catch(e3) { ......
<%
'
Set http=Server.CreateObject("Microsoft.XMLHTTP")
http.Open "GET","http://127.0.0.1/1.xml",False
http.send
Dim xml
Set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = False
'xml.load (Server.MapPath("1.xml")) '如果不是远程文件直接这一步
xml.Load(http.ResponseXML)
Dim t ......
本文将为大家简单比较ASP.NET 3.5与ASP.NET 4.0之间主要差别,希望能对大家了解ASP.NET新特性有所帮助。
ASP.NET 3.5中下列特性是之前的版本中没有的:
·Ajax集成
·LINQ
·自动属性
·Lambda表达式
同样,我希望每个人都弄清楚ASP.NET 3.5和它的下一个版本ASP.NET 4.0 ......