Solved

Using request.querystring in a hyperlink

Posted on 2006-06-26
11
917 Views
Last Modified: 2008-01-09
Hi Experts

I need to link from an html page to a website passing a Value sent from a previous ASP page using Request.Querystring.

The value is passed ok to my html but using this code:

<a href="http://www.streetmap.co.uk/streetmap.dll?postcode2map?code=<%= Request.Querystring("Postcode")" %>"" target="_blank" class="rev">Click here</a> for Direction Map</font></p>

does not pickup the value of Postcode from the existing page. Is there a problem with this syntax ?

Thanks
RangerLad
0
Comment
Question by:RangerLad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 7

Expert Comment

by:pradeepsudharsan
ID: 16984272
<a href="http://www.streetmap.co.uk/streetmap.dll?postcode2map?code='<%= Request.Querystring(Postcode) %>' "   target='_blank' class='rev'>Click here</a> for Direction Map</font></p>
0
 

Author Comment

by:RangerLad
ID: 16984603
Using your suggestion the string

http://www.streetmap.co.uk/streetmap.dll?postcode2map?code='<%= Request.Querystring(Postcode) %>' is created. It should pick up the value of Postcode
0
 
LVL 15

Expert Comment

by:mshogren
ID: 16984862
Is Postcode in the querystring of the URL for the page you start on?  Or is Postcode a field on that page?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:RangerLad
ID: 16984924
the url of the page I am linking from is

http://www.website.com/administration/email_conf.asp?EnquiryID=17636&Postcode=HP289AP

so the value is there, the problem seems to be with the syntax as it is returning the string rather than the value of Postcode
0
 
LVL 15

Expert Comment

by:mshogren
ID: 16984999
Try

<a href="http://www.streetmap.co.uk/streetmap.dll?postcode2map?code=<%= Request.Querystring('Postcode') %>" target="_blank" class="rev">Click here</a> for Direction Map</font></p>
0
 

Author Comment

by:RangerLad
ID: 16985080
This creates the link http://www.streetmap.co.uk/streetmap.dll?postcode2map?code=<%= Request.Querystring('Postcode') %>
0
 
LVL 7

Expert Comment

by:pradeepsudharsan
ID: 16990212
<a href="http://www.streetmap.co.uk/streetmap.dll?postcode2map?code='<%= Request.Querystring("Postcode") %>' "   target='_blank' class='rev'>Click here</a> for Direction Map</font></p>

0
 
LVL 7

Expert Comment

by:pradeepsudharsan
ID: 16990252
Hi,

the correct answer is
<a href="http://www.streetmap.co.uk/streetmap.dll?postcode2map?code=<%= Request.Querystring("Postcode") %>"   target='_blank' class='rev'>Click here</a> for Direction Map</font></p>
--It works perfectly for me.
Ex:
It gives
 code=10

The previous one gives code='10'

regards
pradeep
0
 

Author Comment

by:RangerLad
ID: 17011083
Was this in a html page ? I can only get it to run on an ASP page. Unfortunately, this must be on html as the resulting code (after some fixed text is replaced by an asp script) is formatted into the body of an email which is where I need the link to show.

I will add another 500pts to a linked question if anybody can come up with a suggestion of ow this can be done

Thanks
RangerLad
0
 
LVL 36

Accepted Solution

by:
Zyloch earned 250 total points
ID: 17026176
Yes, Request.Querystring must be run in an ASP page. In particular, grabbing values from the URL can be done in two ways. The most reliable and simple way is through server-side languages such as ASP or PHP. The other way is with client-side scripting.

Now, how does your ASP script parse the text of your email? If the text is retrieved from another page (I am not certain how to do this in ASP, but it would be roughly equivalent to PHP file_get_contents()), then it should pose no problem if the page is in ASP as it will be processed by the server and the string you will grab will have the correct link in it.

If the HTML page is stored in a string within the ASP parsing page, just concatenate the value of Request.Querystring to your HTML link. I am weak in ASP, but I will use pseudocode to demonstrate what I mean:

<%

' Declare a string variable

' Now the string is set
myStr = "<html> ... <a href='...?code=" & Request.Querystring("Postcode") & "'>...</html>"

' Somehow send the string in a HTML email

%>

I do not see any way of doing this client-side if it is going to be an email as scripts cannot run in emails anyways.

Apart from the general problem you are having, I am wondering if your URL is supposed to have two ? in it; usually there is only one.

Ted
0
 

Author Comment

by:RangerLad
ID: 17029889
Ted

Thanks for your input, it answered the key question that you cannot use Request.Querystring from and html page. I have gotten around this by using two sections of html aroung an asp script that returns the required variable and it seems to work fine. Cheers again for your help

Rangerlad
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Change how page is organized 3 51
Link Anchor Not working 9 67
Html using "Or" in condition 3 41
A responsive image gallery using flexbox 6 78
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question