Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 21st, 2006, 09:50 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default URL encode problem

I have a page with a quick nav due to its length. The following link works well:

http://localhost/MHQ-MC/fics.asp?gid=2#risk160

The page scrolls to the location of the anchor named the same. However for other reasons I wish to execute this URL using a response.redirect and are having troubles I believe because of the #

EG:
goToRisk = "fics.asp?gid=" & trim(request("gId")) & "#risk" & session("TempRID")
response.redirect(goToRisk)

FYI: goToRisk printed to the browser shows:
http://localhost/MHQ-MC/fics.asp?gid=2#risk160


Once the code is executed (the redirect) the address in the browser is:
http://localhost/MHQ-MC/fics.asp?gid=2#
This gives a 404 error of course. However if I append the 'risk160' it hits the in page anchor as it should. Any ideas about this?

Based on:
http://www.blooberry.com/indexdot/ht...rlencoding.htm
I have tried encoding the using char(23),char(25),#035; and # EG:

goToRisk = "fics.asp?gid=" & trim(request("gId")) & char(23) & "risk" &...

still no luck, same result...

Them I found this site which has an encoder and decoder:
http://www.auditmypc.com/html-encoder.asp

So I paste in the URL:
http://localhost/MHQ-MC/fics.asp?gid=2#risk160

Which gives me this:

http%3A%2F%2Flocalhost%2FMHQ%2DMC%2Ffics%2Easp%3Fg id%3D2%23risk160

This also failed. Any ideas would be appreciated

TYIA


Wind is your friend
Matt
__________________
Wind is your friend
Matt
 
Old August 22nd, 2006, 07:22 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Have you physically tried:

goToRisk = "fics.asp?gid=" & trim(request("gId"))& "%23risk"

?

"The one language all programmers understand is profanity."
 
Old August 22nd, 2006, 06:21 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Yes I tried %23 and around six other suggestions based on a Google search. Nonw od these work. In fact I looked at it so long yesturday I had a collegue pier review my code, both of us still couldnt figure it out.

I decided to place some different syntax in the redirect location string. For god knows what reason it worked. Very good but very wierd all the same. Anybody suffering the same issue, the working code is:

child window condition after post; does insert then closes its self and refreshes the parent:

if trim(request.form("editingID")) <> "" then
   session("TempfID") = trim(request.form("FicID"))
   sql = "UPDATE fics set .. %>
<script language = JavaScript>
  opener.history.go(0);
  self.close();
</script>
<% end if %>

Placed at the top of the parent:

if session("TempRID") <> "" then
   goToRisk = "fics.asp?gid=" & trim(request("gId")) & "#risk_" & trim(session("TempRID"))
   session("TempRID") = ""
   Response.Redirect(goToRisk)
end if

The destination anchor on the parent page:

<a href="fics.asp?gid=<%= trim(request("gId")) %>#risk_<%= getTask(0) %>" name="risk_<%=getTask(0)%>">

Im still not sure why the underscore (the only thing I changed) made it work. BTW using code like the %23 suggestion simply places %23 in the address bar. Of course this will not communicate with the bookmark.

Wind is your friend
Matt
 
Old August 23rd, 2006, 07:46 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Very true that it wont communicate with the anchor, my thought was though, is that when you requested the QueryString Data you could simply replace %23 with # which then could communicate with the anchor. In any case, glad you got it working.

"The one language all programmers understand is profanity."





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Encode image to base64? OniShirox Javascript How-To 4 July 5th, 2007 03:10 AM
How can I encode the stream?HELP! HandSomeLi All Other Wrox Books 0 March 9th, 2004 06:21 AM
need help on auto encode rachelwong ASP.NET 1.0 and 1.1 Basics 1 December 11th, 2003 12:37 AM
encode alihussein3 Javascript 1 October 28th, 2003 05:21 AM
URL Encode ashwin_f16 VBScript 0 September 18th, 2003 01:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.