Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code Converting

Status
Not open for further replies.

YodaMan81

Technical User
Jul 8, 2003
94
0
0
US
I am trying to write something in ASP and have come across an error. I am not sure if it is because of how I took the statement I had and wrote it in ASP.

If someone could please verify if I did it correctly, it would be greatly appreciated.

Sentence I want to convert:
<Td><a href="javascript: sortTable(0)">CD</a></td>

Sentence I think is right:
Response.Write("<TD><a href=""javascript: sortTable(0)" & """>" & "CD" & "</A></TD>")

-Thanks
 
I use single rather than double quotes with no problems. This will make the line much simpler.
Does this work for you?

Response.Write("<TD><a href='javascript: sortTable(0)'>CD</A></TD>")


 
Your code does produce this:
<TD><a href="javascript: sortTable(0)">CD</A></TD>

BUT

Why is do you concatenated strings?

This is shorter:
Code:
Response.Write("<TD><a href=""javascript: sortTable(0)"">CD</A></TD>")

ttmug.gif
 
Whenever possible, if the HTML/Javascript includes double quotes or other stuff that has to be escaped I try to just drop of out ASP and let the "pre-compiler" fix it (not really a compiler, can't think of the words), like this:
Code:
'Your ASP here
%>
<Td><a href="javascript: sortTable(0)">CD</a></td>
<%
'Your ASP here
 
I usually write a large parts in script and don't switch between HTML and script a lot. It was my believe that switching has a negative impact on performance. But then came this and that was a surprise. As for readability: when you create your page as much as possible in HTML and use <% %> blocks to add the script parts, this tends to become more cryptomanic (IMHO).

ttmug.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top