| Home | Passing Special Characters through URL | KV's Kool ASP | |||||||||||||||||||||||||
|
Passing Special Characters through URL You can pass values to an asp page along with the URL (hyperlink). We use Request.QueryString in the destination asp page to read the values sent by the other page. For example, I want to send "hello" to a page called "callme.asp", then we have to write the following: <a href="callme.asp?value=hello" target="_blank">click me</a> Click here to see how this works! What will happen if the value contains some special characters such as slash, blank space, question mark or an ampersand? Say for example, you have to pass "#51/63, Dave & Jacob Street" to the next page. And you have written the script in the same way as I have written above: <a href="callme.asp?value=#51/63, Dave & Jacob Street" target="_blank">click me</a> Click here to see how this works! You didn't get the expected result. Your result will be based on the browser you are using. Internet Explorer can convert many of these special characters into URL encoded characters, where as Netscape Navigator cannot. Especially, if there is an ampersand (&) in the value you are passing, Internet Explorer also will treat it as delimiter between values and truncate the value there itself. URLEncoding is a method to convert special characters into a browser understandable code. This can be done using Server.URLEncoding method in ASP. The above example has to be written as follows: <a href="callme.asp?value=<%=Server.URLEncode("#51/63, Dave & Jacob Street")%>" target="_blank">click me</a> Click here to see how this works! So, don't forget to use URLEncode when passing values through URL. |
||||||||||||||||||||||||||
| Refer this site | ASPAlliance.com | Contact Us | Join | Advertise | Best Viewed with IE 4.0 or above | ||||||||||||||||||||||||||