Solved

ASP "Quotes" Problem

Posted on 1998-11-04
4
152 Views
Last Modified: 2013-12-25
Im setting up a web-based form which will gather a product description, and then store it in an Access database using ASP.

A few folks have used quotes ("'s) in their descriptions.  These quotation marks within the description, when read into another web-based editing form, chop the description at the first ".

Is there any way around this without having the users enter &qout in place of quotation marks?
0
Comment
Question by:chilcote
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
sybe earned 150 total points
ID: 1856105
1.
Before storing the description into the database, you should "escape" the quote: replace it with two times the quote. Use the replace function for that:

EscapedString = REPLACE(String,CHR(39),CHR(39)&CHR(39))

2. Use Server.HTMLEncode(string) before storing the data in your database. All code will then be encoded into HTML.

3. Use Server.URLEncode before storage in the database (and URLDecode when displaying)


0
 
LVL 1

Expert Comment

by:rajgn
ID: 1856106
chilcote:

I think you't having problems with a " and not with '
In that case you can use a small VB Script function in your 'asp' which takes a string argument and returns another string after replacing " with " which you can display in a form or in HTML. Here it is.

function replaceQuote(str)
  if Instr(str, Chr(34)) then
    str = Replace(str, Chr(34), """)
  end if
  replaceQuote = str
end function

if 'aVariable" is a string containing "s then the statement
  aVariable = replaceQuote(aVariable)
will replace "s with "
0
 
LVL 1

Expert Comment

by:rajgn
ID: 1856107
In the above case you need not bother before storing the data into database
0
 

Author Comment

by:chilcote
ID: 1856108
Much obliged.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now