470,821 Members | 2,068 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,821 developers. It's quick & easy.

Query string in asp page

In asp how How can i pass a parameter value with a space in the value

like this

test.asp?catalog=aValue&lineitem=ladies cloths

I get a %20 as a space in the browser window,
Regards
Don
Jul 19 '05 #1
4 10725
Don,

Usually the %20 doesn't cause problems for me, but if you have to keep the
space, you might try:

<%
query = request.querystring("query")
query = Replace(query, "%20", " ")
response.write query
%>
<a href="test.asp?query=my name">Click me</a>

The replace function here removes any '%20' it finds and replaces it with a
space

Hope this helps.

Gram
Jul 19 '05 #2
Gram wrote:
[snip replace function]
The replace function here removes any '%20' it finds and replaces it with a
space


This won't work due to the nature of the HTTP standard (should be
somewhere within RFC 2616).
Because a http query string cannot contain spaces within a request
(blanks are userd as separators f.ex. "GET index.html") they are being
replaced by your browser automatically. Therefore some kind of
server-sided replace function will not work - and even should not work.
However, your webserver knows about this and replaces all %20 with
spaces so you can access your variables again with spaces instead of %20.

This does affect other special characteres as well. There is a
server-function that you can use to encrypt a string before processing
your document to the client: Server.HTMLencode (SomeString)

Jul 19 '05 #3
Or Server.URLEncode(SomeString)

Ray at home

"Kai Boenke" <ka********@de.bosch.com> wrote in message
news:bm**********@ns2.fe.internet.bosch.com...
Gram wrote:
[snip replace function]
The replace function here removes any '%20' it finds and replaces it with a space


This won't work due to the nature of the HTTP standard (should be
somewhere within RFC 2616).
Because a http query string cannot contain spaces within a request
(blanks are userd as separators f.ex. "GET index.html") they are being
replaced by your browser automatically. Therefore some kind of
server-sided replace function will not work - and even should not work.
However, your webserver knows about this and replaces all %20 with
spaces so you can access your variables again with spaces instead of %20.

This does affect other special characteres as well. There is a
server-function that you can use to encrypt a string before processing
your document to the client: Server.HTMLencode (SomeString)

Jul 19 '05 #4
Ray at <%=sLocation%> wrote:
Or Server.URLEncode(SomeString)

"Kai Boenke" <ka********@de.bosch.com> wrote in message
news:bm**********@ns2.fe.internet.bosch.com...
[snip other stuff]
This does affect other special characteres as well. There is a
server-function that you can use to encrypt a string before processing
your document to the client: Server.HTMLencode (SomeString)


You are right.
"Server.HTMLencode (SomeString)" actually does something different (not
completely but useless in this case): Converting characters to HTML
entities.

Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Harvey | last post: by
3 posts views Thread by Dr. Oz | last post: by
10 posts views Thread by Onur Bozkurt | last post: by
8 posts views Thread by Jim in Arizona | last post: by
1 post views Thread by TF | last post: by
reply views Thread by =?Utf-8?B?SnVsaWEgQg==?= | last post: by
5 posts views Thread by =?Utf-8?B?SnVsaWEgQg==?= | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.