Need help in formulating a HREF link

J

Jack

Hi,
I am trying to get a printer.asp page linked back to a main report page.
However, in the final url, the grantid is missing which should not be, if the
href statement is correct. I checked the correct value of grantid via
response.write and I can see the correct value. However, the href statement
cannot pick the value properly. Any help is appreciated. Thanks.
CODE:
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY text = "red">
<center>
<b>

Printable.asp page <br>
This page is under construction.<br>
<%
GrantID = Session("sess_GrantID")
Response.Write "<br>"
Response.Write GrantID & "<br>"
Response.Write "<A HREF=""mainreportagain1.asp?GrantID="" & GrantID>Click to
return to main report page</A>"
%>
</b>
</center>
</BODY>
</HTML>

THE url of the clicked to e is:

http://localhost/gwisbrandnewready3/mainreportagain1.asp?GrantID=

while the correct url of the clicked to page will be:

http://localhost/gwisbrandnewready3/mainreportagain1.asp?GrantID=5718
 
A

Aaron [SQL Server MVP]

Response.Write said:
return to main report page</A>"

How about:

Response.Write "<A HREF=mainreportagain1.asp?GrantID=" & GrantID & ">Click
to return to main report page</A>

Leave out the double-double quotes unless they are actually necessary; all
they seem to do is add confusion. If you really think you need quotes
there, then use single quotes:

Response.Write "<A HREF='mainreportagain1.asp?GrantID=" & GrantID & "'>Click
to return to main report page</A>

Then you don't have to escape them, and it's a little clearer which quotes
are which, IMHO.
 
R

Ray Costanzo [MVP]

This code should not be able to run without error. Actually, it probably
is, but your error string is in the href attribute property, so you're not
seeing. A view source would probably reveal something like:



<A HREF="mainreportagain1.asp?GrantID=---------------------------
....
Error: Expected end of statement
Code: 800A0401
....


You need to put strings in quotes, or just stop response.writing everything.

Response.Write "<A HREF=""mainreportagain1.asp?GrantID="" & GrantID &
""">Click to
return to main report page</A>"

or
%>
<a href="mainreportagain1.asp?grantid=<%=GrantID%>">Click to return to main
report page</a>
 
A

Aaron [SQL Server MVP]

No, you're missing a double-quote (count them up!). I get:

Microsoft VBScript compilation error '800a0401'
Expected end of statement

--
http://www.aspfaq.com/
(Reverse address to reply.)
 
J

Jack

Thanks to Aaaron, Ray and Curt for each of the wonderful advise. I am going
to check each of those out now. Regards to everybody.
 
J

Jack

I applied Ray's second method:
<a href="mainreportagain1.asp?grantid=<%=GrantID%>">Click to return to main
report page</a>
and it works fine now. Regards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,156
Latest member
KetoBurnSupplement
Top