×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

handling special characters in asp
2

handling special characters in asp

handling special characters in asp

(OP)
hi,

Does anyone have any idea as to what might be causing the following:

I have a hyperlink which reoloads an asp with querystrings
x,y,z.

x,y and z load values like C1,VR,7T into correlating text boxes.

Everything works fine except when x,y or z contains values with special characters like C#,B+ or #I..

Does anyone know what I can do to alleviate this?

Any help sure would be appreciated a lot!

RE: handling special characters in asp

The reason that you are having a problem is because url's cannot contain those characters. You may notice when you have a space in a url it changes it to %20. There is a function ASP to convert a string to a valid url, Server.URLEncode(str) will encode the special characters in str to be ok.
-tarwn

RE: handling special characters in asp

2
yea what tawrn said.

RE: handling special characters in asp

Try
Response.Write Server.HTMLEncode(strToSend)
for data that might contain Special characters.

www.VBResizer.com Generate Forms/Controls Resizing/Tabbing Class
www.VBCompare.com Compare Code (Text)
www.VBSortGen.com Generate Sort Class in VB or VBScript

RE: handling special characters in asp

(OP)
Hi guys,

thanks for all your input - but I've tried (sorry forgot to mention) server.urlencode and server.htmlencode already and still i'm having this problem - don't know why..

RE: handling special characters in asp

can you show us the code used to get the querystring data and then redirect

RE: handling special characters in asp

(OP)
heres the link on my page which reloads the page with querystring values:

<a href="service.asp?z=<% server.urlencode(Response.write(rst("SERVICE_CD")))%> &x=<% Response.write(rst("DESC1"))%> &y=<% Response.write(rst("DESC2"))%> &aa=<% Response.write(rst("DESC3"))%>">Edit</a>

.. the querystring "z" uses urlencode (i've also tried htmlencode).

thanks guys and gals

RE: handling special characters in asp

<a href="service.asp?z=<% server.urlencode(rst("SERVICE_CD"))%> &x=<% Response.write(rst("DESC1"))%> &y=<% Response.write(rst("DESC2"))%> &aa=<% Response.write(rst("DESC3"))%>">Edit</a>

RE: handling special characters in asp

Ah, forget what i said above, try this:

<%

Dim Service_cd, desc1, desc2, desc3


'#put all data in a string...

Service_cd = Server.URLencode(rst("Service_CD"))
desc1 = Server.URLencode(rst("DESC1"))
desc2 = Server.URLencode(rst("DESC2"))
desc3 = Server.URLencode(rst("DESC3"))

'# NOTE: <%="An "=" sign is the same as using response.write"%>

<a href="service.asp?z=<%=Service_cd%>&x=<%=desc1%>&y=<%=desc2%>&aa=<%=desc4%>">Edit</a>




%>

RE: handling special characters in asp

(OP)
Thanks snowboardr!

that hit the spot!
my code works fine now - amazing!

cheers!

RE: handling special characters in asp

Snowboardr,

I want to try your code fix but don't quite understand what you're doing. Can you break it down for me... I'm a beginner. Thanks.

Your code read:
<%

Dim Service_cd, desc1, desc2, desc3


'#put all data in a string...

Service_cd = Server.URLencode(rst("Service_CD"))
desc1 = Server.URLencode(rst("DESC1"))
desc2 = Server.URLencode(rst("DESC2"))
desc3 = Server.URLencode(rst("DESC3"))

'# NOTE: <%="An "=" sign is the same as using response.write"%>

<a href="service.asp?z=<%=Service_cd%>&x=<%=desc1%>&y=<%=desc2%>&aa=<%=desc4%>">Edit</a>




%>

RE: handling special characters in asp

this might be of assistance as well in your issue :
it's just the reverse of a URLEncode, i still have yet to write a HTMLDeCode

CODE

function URLDecode(str)
    dim re
    set re = new RegExp
    str = Replace(str, "+", " ")
    re.Pattern = "%([0-9a-fA-F]{2})"
    re.Global = True
    URLDecode = re.Replace(str, GetRef("URLDecodeHex"))
end function

' Replacement function for the above
function URLDecodeHex(match, hex_digits, pos, source)
    URLDecodeHex = chr("&H" & hex_digits)
end function

DreX
aKa - Robert

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close