Welcome to WebmasterWorld Guest from

Forum Moderators: ocean10000

Message Too Old, No Replies

Escaping single and double quote from string

7:55 pm on Oct 22, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 13, 2004
posts: 64
votes: 0

I am fairly new to ASP and have noticed that apostrophes in data driven variables can cause code to break or not display since a single quote is a comment.

I have an instance where I am calling a string from a database text field to show content in a mouseover tooltip. It works great as long as there is not a single or double quote in the text.

What is the best way to escape single and double apostrophes?


I tried this, but it seems pretty silly and did not work ...

<%=Replace(Replace(strDescription, "'", "\'"), """, "\"")%>

8:48 am on Oct 23, 2008 (gmt 0)

New User

10+ Year Member

joined:Oct 14, 2008
votes: 0

There are a few ways to overcome this, probably the most simple is the following


Try that



[edited by: Matt_C at 8:55 am (utc) on Oct. 23, 2008]