473,508 Members | 2,303 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 14895
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
6508
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
58
10048
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
22
25548
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
3
1696
by: Brian | last post by:
Hope someone can help ..... Have a function which creates a HTML HREF function fLink(aText) { return '<a href=javascript:DoLinkSearch("'+aText+'")>'+aText+'</a>'; } If the parameter value is...
1
1665
by: I.am.the.Buddha | last post by:
I am still learning asp and sql. I am having trouble with passing a variable to within an sql statement. I am sure it is something simple like misuse of quotes. Since it may help if i say what i...
5
1756
by: nephish | last post by:
hey there, can anyone tell me if this is legal php/mysql ? i am trying to write a simple function to get a single stat from a single table. eg.. $field = 'phone_number'; $customer = 'fred';
0
2406
by: kencana | last post by:
hi All, I got problem in passing data (more than one) from soap client to the soap server. but if i only passing one data at a time, it works successfully.. The following is the error message i...
6
7277
by: rynato | last post by:
I am embarrassed that I cannot figure this out, as it seems fairly simple. I found a JS function I'd like to use, which animates a layer so that it moves across the screen. The problem is the...
5
9841
by: moni | last post by:
Hi.. I am trying to use javascript for google maps display. If I call the javascript function from my aspx file I use: <input type="text" id="addresstext" value="Huntington Avenue,...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7120
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.