469,290 Members | 1,882 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Passing Quotes in a URL Call

Using ASP 3.0

I want to dynamically build a call to another asp page and include some
parameters as part of the call. The basic format of the call is something
like::

"<a href='mypage.asp?id=" & theid & "&location='" & thelocation &
"'>GO</a>"

where there is a single quote followed by a double quote following the
...location=... and vica-versa after the variable

My problem is that the variable thelocation can include a single quote or a
double quote. I tried Server.URLEncode and that didn't work. I got a string
that ended up causing a Page Not Found (it encoded the dot in the page name
and that didn't work)

How can I encode the data so that quotes will be accepted in this type of
call?

Wayne
Jul 19 '05 #1
4 14394
Did you decode the URL at the other end when you encoded
it?

Try the following code before you reconstruct the call to
the page..

<%
Function myURLDecode(strString)
strString = Replace(strString, "%2F", "/")
strString = Replace(strString, "%7C", "|")
strString = Replace(strString, "%3F", "?")
strString = Replace(strString, "%21", "!")
strString = Replace(strString, "%40", "@")
strString = Replace(strString, "%5C", "\")
strString = Replace(strString, "%23", "#")
strString = Replace(strString, "%24", "$")
strString = Replace(strString, "%5E", "^")
strString = Replace(strString, "%26", "&")
strString = Replace(strString, "%25", "%")
strString = Replace(strString, "%2A", "*")
strString = Replace(strString, "%28", "(")
strString = Replace(strString, "%29", ")")
strString = Replace(strString, "%7D", "}")
strString = Replace(strString, "%3A", ":")
strString = Replace(strString, "%2C", ",")
strString = Replace(strString, "%7B", "{")
strString = Replace(strString, "%2B", "+")
strString = Replace(strString, "%2E", ".")
strString = Replace(strString, "%2D", "-")
strString = Replace(strString, "%7E", "~")
strString = Replace(strString, "%2D", "-")
strString = Replace(strString, "%5B", "[")
strString = Replace(strString, "%5F", "_")
strString = Replace(strString, "%5D", "]")
strString = Replace(strString, "%60", "`")
strString = Replace(strString, "%3D", "=")
strString = Replace(strString, "%27", "'")
strString = Replace(strString, "+", " ")
strString = Replace(strString, "%22", Chr(34))
myURLDecode = strString
End Function
%>
Jul 19 '05 #2

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Using ASP 3.0

"<a href='mypage.asp?id=" & theid & "&location='" & thelocation &
"'>GO</a>"

where there is a single quote followed by a double quote following the
..location=... and vica-versa after the variable

My problem is that the variable thelocation can include a single quote or a double quote. I tried Server.URLEncode and that didn't work. I got a string that ended up causing a Page Not Found (it encoded the dot in the page name and that didn't work)


Sounds like you were possibly trying Server.URLEncode in the wrong place...

I would say this should work :

Response.write "<a href='mypage.asp?id=" & Server.URLEncode(theid) &
"&location='" & Server.URLEnCode(thelocation) & "'>GO</a>"
Jul 19 '05 #3
Thanks Dan. You were right. I used the URLEncode on the whole call instead
of just the pieces that needed it.

Wayne

"Dan Boylett" <ms*******@crossdata.co.uk> wrote in message
news:ek**************@TK2MSFTNGP10.phx.gbl...

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Using ASP 3.0

"<a href='mypage.asp?id=" & theid & "&location='" & thelocation &
"'>GO</a>"

where there is a single quote followed by a double quote following the
..location=... and vica-versa after the variable

My problem is that the variable thelocation can include a single quote
or a
double quote. I tried Server.URLEncode and that didn't work. I got a string
that ended up causing a Page Not Found (it encoded the dot in the page

name
and that didn't work)


Sounds like you were possibly trying Server.URLEncode in the wrong

place...
I would say this should work :

Response.write "<a href='mypage.asp?id=" & Server.URLEncode(theid) &
"&location='" & Server.URLEnCode(thelocation) & "'>GO</a>"

Jul 19 '05 #4
Very Handy function. Thanks

Wayne

"Kevin" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
Did you decode the URL at the other end when you encoded
it?

Try the following code before you reconstruct the call to
the page..

<%
Function myURLDecode(strString)
strString = Replace(strString, "%2F", "/")
strString = Replace(strString, "%7C", "|")
strString = Replace(strString, "%3F", "?")
strString = Replace(strString, "%21", "!")
strString = Replace(strString, "%40", "@")
strString = Replace(strString, "%5C", "\")
strString = Replace(strString, "%23", "#")
strString = Replace(strString, "%24", "$")
strString = Replace(strString, "%5E", "^")
strString = Replace(strString, "%26", "&")
strString = Replace(strString, "%25", "%")
strString = Replace(strString, "%2A", "*")
strString = Replace(strString, "%28", "(")
strString = Replace(strString, "%29", ")")
strString = Replace(strString, "%7D", "}")
strString = Replace(strString, "%3A", ":")
strString = Replace(strString, "%2C", ",")
strString = Replace(strString, "%7B", "{")
strString = Replace(strString, "%2B", "+")
strString = Replace(strString, "%2E", ".")
strString = Replace(strString, "%2D", "-")
strString = Replace(strString, "%7E", "~")
strString = Replace(strString, "%2D", "-")
strString = Replace(strString, "%5B", "[")
strString = Replace(strString, "%5F", "_")
strString = Replace(strString, "%5D", "]")
strString = Replace(strString, "%60", "`")
strString = Replace(strString, "%3D", "=")
strString = Replace(strString, "%27", "'")
strString = Replace(strString, "+", " ")
strString = Replace(strString, "%22", Chr(34))
myURLDecode = strString
End Function
%>

Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

22 posts views Thread by Arne | last post: by
3 posts views Thread by Brian | last post: by
6 posts views Thread by rynato | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.