Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
| Search | Today's Posts | Mark Forums Read
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 30th, 2003, 05:21 PM
Registered User
 
Join Date: Dec 2003
Location: Batesville, Indiana, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ggriffit
Default Showing single and double quote in text field.

Hello All,

I have a table in a database that has some fields with single and double quotes in it. I need to show some of these fields in a text field. However when I try to do this it thinks that the value ends when it sees the quotes. Is there a way to get around this?

Thanks!

Grant Griffith
  #2 (permalink)  
Old December 30th, 2003, 06:01 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: High Wycombe, UK, United Kingdom.
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

You will need to use the REPLACE command to either replace them with an escaped version of themselves or another character so that they do not cause this issue, for example :

response.write("<input type='text' name'myTxtBox1' value='" & Replace(thevalue,Chr(34),Chr(39)) & "'>")

Replaces the double quote with a space
  #3 (permalink)  
Old December 30th, 2003, 06:24 PM
Registered User
 
Join Date: Dec 2003
Location: Batesville, Indiana, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ggriffit
Default

Greg,

That does not show the single or double quote in the text fields though and I have to show them. Anyone else have an idea?

Grant Griffith
  #4 (permalink)  
Old December 30th, 2003, 07:22 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You can use Server.HTMLEncode to escape the " characters to &quot; like this:

Response.Write("<input type=""text"" value=""" & Server.HTMLEncode("String""With''Singe and Double Quotes""") & """>")

This will write out a text box with single and double quotes in it.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #5 (permalink)  
Old January 5th, 2004, 11:19 AM
Registered User
 
Join Date: Dec 2003
Location: Batesville, Indiana, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ggriffit
Default

Thanks Imar, that is exactly what I was looking for. I forgot all about the Server.HTMLEncode statement.

Grant Griffith


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can i get rid off the double quote in a text myer75 VBScript 7 April 14th, 2009 07:11 PM
escape double quote inside JavaScript mister_mister XSLT 5 January 23rd, 2008 01:56 PM
single quote problem harpua PHP Databases 1 July 8th, 2005 07:37 AM
replace single Quote qadeerahmad General .NET 3 September 6th, 2004 08:10 PM
Storing single and double quotes in text roniestein Access 4 December 30th, 2003 05:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.