WelcomeServicesPortfolioKnowledge BaseContact Us
27 Seconds, Inc.


Knowledge base View Article

need hosting?

Need hosting? We use and love our host - CrystalTech.com!
Need hosting? We use and love our host - CrystalTech.com!

Text Disguise - CAPTCHA-image/Human Interactive Proof web services

National Holiday Dates and Bank Holiday Dates - web site that provides the dates of national and bank holidays for the United States, United Kingdom, Ireland and Scotland

Holiday Web Service - web services for programmers to provide the dates of national and bank holidays in their applications for the United States, United Kingdom, Ireland and Scotland

Our Family Heart - web site to help families communicate no matter where they are

What?! You haven't heard about the greatest remote controlled flyer to come out in years?! Checkout the FlyTech DragonFly now!

Handle double quotes in a form.

Summary: When pulling data from a form or database you can into trouble if the data contains a double quote (").
 
Keywords: CHR(34)
DOUBLE QUOTE
QUOTE
Applicable Software: Active Server Pages (ASP)
 
Body:

When I was dynamically populating form values, I found that if the data has a double quote (&qout;) in it, it would cut off the data entered in the form.

To solve this, I found that I could simple Server.HtmlEncode the value and all was well. Except when I was populating from a database and the data was NULL which caused an error for Server.HtmlEncode. So, I whipped up this little function:

Function formEncode(formValue)
Dim m_sOut
    m_sOut = formValue

	If IsNull(m_sOut) Then
		m_sOut = ""
	Else
		m_sOut = Server.HTMLEncode(m_sOut)
	End If

	formEncode = m_sOut

End Function

This is used when you assign a value to the form field:

<input type="text" name="example" value="<%=formEncode("The ""test"" is good.") %>">

 
Author: Douglas L. Setzer, II, http://www.27seconds.com
Posted On: 3/5/2002 11:40:54 AM

Rate this article: Average: n/a
n/a12345678910
Comments?

Article Search   |   All Articles

 

 
©2002 27 Seconds, Inc. All Rights Reserved.