special character "&" and " ' " in request.querystring URL

M

magix8

Hi all,


how can I pass the special characters as request.querystring value ?
example like "&", since & is used in request.querystring for various
parameters value

It will be cut off until "pass" in text 1, for example

let say:
text1 = "I want to pass & chacater"

test.asp?Text1=<%=text1%>

should I use Server.URLEncode ? But Server.URLEncode doesn't seems to
work either as I tried
I read some ppl suggested using replace method to replace "&" with
normal letters, and at receiving, replace back with "&", but is there
a better one ?

Special characters like ' ' and & are having problem in
request.querystring URL

Any suggestions or workaround ?

Thanks.

cheers,
Magix
 
E

Evertjan.

(e-mail address removed) wrote on 17 feb 2008 in
microsoft.public.inetserver.asp.general:
how can I pass the special characters as request.querystring value ?
example like "&", since & is used in request.querystring for various
parameters value

It will be cut off until "pass" in text 1, for example

let say:
text1 = "I want to pass & chacater"

test.asp?Text1=<%=text1%>

should I use Server.URLEncode ? But Server.URLEncode doesn't seems to
work either as I tried
I read some ppl suggested using replace method to replace "&" with
normal letters, and at receiving, replace back with "&", but is there
a better one ?

Special characters like ' ' and & are having problem in
request.querystring URL

Any suggestions or workaround ?

Use VBS Escape()
 
M

magix8

(e-mail address removed) wrote on 17 feb 2008 in
microsoft.public.inetserver.asp.general:










Use VBS Escape()

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)- Hide quoted text -

- Show quoted text -



I used:
<script>

var vQText = document.getElementById("Text1").value;
var result = vQText.replace(/&/gi, "%26"); // replace ampersand
</script>

It works fine.

But for single quote, it doesn't seem working.
i.e var result = vQText.replace(/'/gi, "%27"); // replace single quote
 
E

Evertjan.

(e-mail address removed) wrote on 17 feb 2008 in
microsoft.public.inetserver.asp.general:

[please do not quote signatures on usenet]
I used:
<script>

var vQText = document.getElementById("Text1").value;
var result = vQText.replace(/&/gi, "%26"); // replace ampersand
</script>

It works fine.

But for single quote, it doesn't seem working.
i.e var result = vQText.replace(/'/gi, "%27"); // replace single quote

Why noy do this serverside as I suggested?

ASP-VBS:

<% text1 = "I want to pass & chacater" %>

<a href = 'test.asp?Text1=<% = Escape(text1) %>'>

or

ASP-JS:

<% text1 = 'I want to pass & chacater'; %>

<a href = 'test.asp?Text1=<% = escape(text1); %>'>
 
D

Daniel Crichton

Hi all,

how can I pass the special characters as request.querystring value ?
example like "&", since & is used in request.querystring for various
parameters value
It will be cut off until "pass" in text 1, for example
let say:
text1 = "I want to pass & chacater"

should I use Server.URLEncode ? But Server.URLEncode doesn't seems to
work either as I tried
I read some ppl suggested using replace method to replace "&" with
normal letters, and at receiving, replace back with "&", but is there a
better one ?

What didn't work with Server.URLEncode?

Response.Write Server.URLEncode("I want to pass & character")

spits out

I+want+to+pass+%26+character

which is correct.

Did you try

test.asp?Text1=<%=Server.URLEncode(text1)%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top