469,333 Members | 4,608 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,333 developers. It's quick & easy.

Regarding the quotes in a hyperlink in ASP

Hi I just want to write a hyperlink in ASP. getting many errors . can anyone please help me with this....

Response.Write("<font size=2 face=arial><A Class=TableLink HREF="http://cs-dev.govt.com/csscripts/login.asp?K=1234&srcserver=cs" & "onMouseOver=" & """" & "window.status='Case';return true" & """" & "onMouseOut=" & """" & "window.status='';return true" & """" & ">Case:</A></font></td>")
Oct 26 '07 #1
6 1405
markrawlingson
346 Expert 100+
You're breaking the string. The quote at the beginning of the http://.... is being interpretted as an END quote, and the link http://... is being looked at as a variable or an object by ASP.

There are several ways to get around this.

1) Use single quotes.
2) Use 3 double quotes, not 1.
3) Use Chr( 34 ), which is a quote, but not interpretted by ASP as an ending to your string. I use Chr( 34 ) in my code, I don't like the other two methods very much.

Expand|Select|Wrap|Line Numbers
  1. Response.Write "<font size=2 face=arial><A Class=TableLink HREF=" & Chr( 34 ) & "http://cs-dev.govt.com/csscripts/login.asp?K=1234&srcserver=cs" & Chr( 34 ) & " onMouseOver=" & Chr( 34 ) & "window.status='Case';return true" &  Chr( 34 ) & " onMouseOut=" & Chr( 34 ) & "window.status='';return true" & Chr( 34 ) & ">Case:</A></font></td>"
  2.  
Sincerely,
Mark
Oct 26 '07 #2
You're breaking the string. The quote at the beginning of the http://.... is being interpretted as an END quote, and the link http://... is being looked at as a variable or an object by ASP.

There are several ways to get around this.

1) Use single quotes.
2) Use 3 double quotes, not 1.
3) Use Chr( 34 ), which is a quote, but not interpretted by ASP as an ending to your string. I use Chr( 34 ) in my code, I don't like the other two methods very much.

Expand|Select|Wrap|Line Numbers
  1. Response.Write "<font size=2 face=arial><A Class=TableLink HREF=" & Chr( 34 ) & "http://cs-dev.govt.com/csscripts/login.asp?K=1234&srcserver=cs" & Chr( 34 ) & " onMouseOver=" & Chr( 34 ) & "window.status='Case';return true" &  Chr( 34 ) & " onMouseOut=" & Chr( 34 ) & "window.status='';return true" & Chr( 34 ) & ">Case:</A></font></td>"
  2.  
Sincerely,
Mark
i m gettin the same out put.i m not gettin the hyperlink !!!!!!!!!
Oct 26 '07 #3
Thanks brother i m gettin it now!!!!!!!!!!
Oct 26 '07 #4
jhardman
3,406 Expert 2GB
For the problems you illustrated I agree with Mark. It is easier to write chr(34) than try to remember how many quote marks you have used and whether you are within a string at any given point.

Another option is to put the link outside of the ASP delimiters:
Expand|Select|Wrap|Line Numbers
  1. 'code here %>
  2. <font size=2 face=arial><A Class=TableLink HREF="http://cs-dev.govt.com/csscripts/login.asp?K=1234&srcserver=cs" onMouseOver="window.status='Case';return true" onMouseOut="window.status='';return true">Case:</A></font></td>
  3. <%
  4. 'continue code
Of course it is up to you to decide when to switch between ASP and HTML code, but I tend to switch to HTML when I need to write a lot of quote marks.

Jared
Oct 28 '07 #5
For the problems you illustrated I agree with Mark. It is easier to write chr(34) than try to remember how many quote marks you have used and whether you are within a string at any given point.

Another option is to put the link outside of the ASP delimiters:
Expand|Select|Wrap|Line Numbers
  1. 'code here %>
  2. <font size=2 face=arial><A Class=TableLink HREF="http://cs-dev.govt.com/csscripts/login.asp?K=1234&srcserver=cs" onMouseOver="window.status='Case';return true" onMouseOut="window.status='';return true">Case:</A></font></td>
  3. <%
  4. 'continue code
Of course it is up to you to decide when to switch between ASP and HTML code, but I tend to switch to HTML when I need to write a lot of quote marks.

Jared

Actually i used it like this now

Response.Write("<td><A Class=TableLink HREF = 'http://cs-dev.govt.com/csscripts/login.asp?K="& SecEncode(Id) &" &srcserver=CS' > " &SecEncode(Id) &" </a> </td>")
.........
it works . but sme how i want this also
onMouseOver="window.status='Case';return true" onMouseOut="window.status='';return true">
but i get an error in the applicaton Unterminated string constant
i knw this means there is as string which is not closed . but i have closed all properly.......
Oct 29 '07 #6
jhardman
3,406 Expert 2GB
... but i have closed all properly.......
That's what I'm talking about. There are so many quote marks it is nearly impossible to keep them straight on the first go, and there is still considerable difficulty cleaning it up. I would recommend you go outside the ASP delimiters:
Expand|Select|Wrap|Line Numbers
  1. <td><A Class="TableLink" HREF="http://cs-dev.govt.com/csscripts/login.asp?K=<%=SecEncode(Id)%>&srcserver=CS" 
  2. onMouseOver="window.status='Case';return true" onMouseOut="window.status='';return true"><%=SecEncode(Id)%></a></td>
Oct 29 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Tim Mulholland | last post: by
4 posts views Thread by Henry Tam | last post: by
1 post views Thread by thenairboy | last post: by
14 posts views Thread by wahaha | last post: by
20 posts views Thread by tshad | last post: by
1 post views Thread by Dave | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by haryvincent176 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.