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)) -
Ïà¹ØÎĵµ£º
ÏÖÏó£ºÆÕͨµÄhtmlÎÄ×ÖÏÔʾÕý³££¬µ«ÓÃresponse.writeµÈasp´úÂëÊä³öµÄÎÄ×־ͳöÏÖÂÒÂë
½â¾ö·½·¨£ºÆð³õÒÔΪÊÇä¯ÀÀÆ÷±àÂë³ö´íµÄÔÒò£¬ËùÓÐÔÚ´úÂëÖмÓÈë
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
µ«»¹ÊdzöÏÖÂÒÂ룬ÎÊÌâû½â¾ö£¬ÉÏÃæµÄ´úÂëÖ¸¶¨µÄÊÇhtml¾²Ì¬ÎÄ×ֵıàÂë
×îºó²é×ÊÁÏ·´Ê¡ÊÇc ......
¡¡¡¡ÔÚASP±à³ÌµÄ¹ý³ÌÖУ¬»ñÈ¡µ±Ç°²Ù×÷µÄÎļþµÄÎļþÃû£¬ÊÇÒ»¸ö·Ç³£³£Óõ͝×÷£¬ASPºÃÏñûÓÐ×Ô¼ºÄÚÖú¯Êý£¬ËùÒÔÕâ¸ö²Ù×÷ÎÒÃÇÐèÒª×Ô¼º±àº¯ÊýÀ´Íê³É¡£½ñÌìÒ»¸öÀÏÅóÓÑÎÊÎÒÔõô×ö£¬ÎÒã¶ÁËһϣ¬»¹ÔÚÏëÓÐûÓÐÄÚÖú¯Êý£¬ÊµÔÚûÏëÆðÀ´£¬²»ÖªµÀÊÇÕæµÄûÓл¹ÊÇÎÒ²»ÖªµÀ¡£ºÇºÇ~²»¹ÜÁË£¬×îºóÎÒ»¹ÊÇ×Ô¼ºÐ´ÁËÒ»¸öСº¯ÊýÀ´Íê³ÉµÄ£¬²»¹ý²»ÊÇÎ ......
´æ´¢½ø³Ì¾ÍÊÇ×÷Ϊ¿ÉÖ´ÐжÔÏó´æ·ÅÔÚÊý¾Ý¿âÖеÄÒ»¸ö»ò¶à¸öSQLÃüÁî¡£
¶¨Òå×ÜÊǺܳéÏó¡£´æ´¢½ø³ÌÆäʵ¾ÍÊÇÄÜÍê³ÉÒ»¶¨²Ù×÷µÄÒ»×éSQLÓï¾ä£¬Ö»²»¹ýÕâ×éÓï¾äÊÇ·ÅÔÚÊý¾Ý¿âÖеÄ(ÕâÀïÎÒÃÇ̸ֻSQL SERVER)¡£Èç¹ûÎÒÃÇͨ¹ý´´½¨´æ´¢½ø³ÌÒÔ¼°ÔÚASPÖе÷Óô洢½ø³Ì£¬¾Í¿ÉÒÔ±ÜÃ⽫SQLÓï¾äͬASP´úÂë»ìÔÓÔÚÒ»Æð¡£ÕâÑù×öµÄºÃ´¦ÖÁÉÙÓÐÈý¸ö£º
µÚÒ»¡ ......
ͨ¹ýʹÓà ASP.NET ÑéÖ¤¿Ø¼þ£¬¿ÉÒÔʹÓÃÂß¼ÔËËã·û¶ÔÕÕÒ»¸öÌØ¶¨ÖµÀ´ÑéÖ¤Óû§ÊäÈë¡£ÀýÈ磬Äú¿ÉÒÔÖ¸¶¨Óû§ÊäÈë±ØÐëÊÇ“1950 Äê 1 Ô 1 ÈÕ”Ö®ºóµÄÈÕÆÚ£¬»òÊÇÒ»¸ö´óÓÚµÈÓÚ 0 µÄÕûÊýÖµ¡£»òÕߣ¬Äú»¹¿ÉÒÔÖ¸¶¨½«Óû§ÊäÈëÓëÁíÒ»¿Ø¼þµÄÖµ½øÐбȽϡ£
1¡¢½« CompareValidator ¿Ø¼þÌí¼Óµ½Ò³Ö ......