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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying the Title containing an apostrophe 1

Status
Not open for further replies.

amorous

Programmer
Sep 5, 2003
1,008
US
Hi Guys...

I have this below piece of code...

Response.Write "<a href='#' title='"&comments(i)&"'> "&commentID&" </a>"

It works fine and displays the comments in a cute little box when the mouse is placed on commentID but....

when comments contain an apostrophe... i get the comments truncated at the apostrophe and displayed in the box...

How can i display the whole comments even if it contains an apostrophe?

Thanks

-VJ
 
Server.HTMLEncode(Value)

where value is comments(i) in this instance...

this converts the string Value to html friendly text ( similar to url encoding) and should prevent breakage due to quotes in the string value

[thumbsup2]DreX
aKa - Robert
 
Thanks Drexor... It did not work...

Here is sequence...

Step 1.I collect the comments entered by the user on the form and submit it to DB using

Replace(request("comments","'","''") <-works fine and data gets inserted into DB finely

Step 2. I am collecting all the comments related to a particular day in one array using a loop and this piece of code

thucomments= thucomments & rsitem("comments")& ","
vjthucomments=Split(thucomments,",")
<--works fine i guess

and then

step 3. I am displaying as a title using

Response.Write "<a href='#' title='"&vjthucomments(i)&"'> "&commentID&" </a>" <-does not work...the comments inside the title box get truncated at the apostrophe...

Any ideas..

-VJ







 
surround the title value with " " instead of singles.

use chr()'s instead of hacking a billion """"" into the build and making maintainability degrade

___________________________________________________________________

onpnt.com
SELECT * FROM programmers WHERE clue > 0
(0 row(s) affected) -->faq333-3811

 
Ah :) if it's just in the HTML text like in the href, then yes the htmlencode should patch you up

you can try to patch it one of several ways :

1st: may not be overly reliable
Response.Write "<a href='#' title='"&replace(comments(i),"'","''")&"'> "&commentID&" </a>"

2nd:
Response.Write "<a href=""#"" title="""&comments(i)&"""> "&commentID&" </a>"

3rd:
' break the asp code to html write it
%>
<a href="#" title="<%=comments(i)%>"><%=commentID%></a>
<%

[thumbsup2]DreX
aKa - Robert
 
Thanks Drexor....

I used the 2nd way and it worked like a charm..

You guys are awesome....I learn a lot from you guys..

Thanks..

-VJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top