Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
Password Reminder
Register
| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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
Reply With Quote
  #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
Reply With Quote
  #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
Reply With Quote
  #4 (permalink)  
Old December 30th, 2003, 07:22 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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.
Reply With Quote
  #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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:20 PM.


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