Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Active Server Pages (ASP)
Expertise: Beginner
Aug 27, 1999

Using URLEncode to Pass Query String Values

Question:
I'm passing a string from one ASP template to another. The string may contain spaces so I call URLEncode, which works well as far as preventing the 400 Error for a malformed page. However, when I encode the Query String, it seems to muck up the code that gets the values from the Query String. Is there a "decode" function that I need to use?

Answer:

When you are passing values in a Query String, you are building a string that looks like this:

page name.asp?key1=value1&key2=value2

Remember to URLEncode only the value1 and value2 strings. Do not URLEncode the key1 and key2 strings. So your code should look like this:

"key1=" & Server.URLEncode("value1") & "&key2=" & Server.UrlEncode("value2")

This code will pass the proper "value1" and "value2" even if they contain spaces or punctuation characters.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap