dcsimg
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

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


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

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


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
Thanks for your registration, follow us on our social networks to keep up-to-date