473,321 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Quotes from database to textbox

I have a form that asks for the size of a particular object. Sometimes the size is 4" X 8". The problem that arises is when the record is pulled back from a database to a textbox in a form; I get an error with HTML. I try and place the 4" X 8" into a text box, like <input type="text" name="size" value="4" X 8""> Is there something I can do in ASP to keep this from happening after the client receives the data?
Jul 19 '05 #1
7 1794
<input type="text" value="<%=Server.HTMLEncode(YourValue)%>">

Ray at work

"Joeandtel" <an*******@discussions.microsoft.com> wrote in message
news:A9**********************************@microsof t.com...
I have a form that asks for the size of a particular object. Sometimes the

size is 4" X 8". The problem that arises is when the record is pulled back
from a database to a textbox in a form; I get an error with HTML. I try and
place the 4" X 8" into a text box, like <input type="text" name="size"
value="4" X 8""> Is there something I can do in ASP to keep this from
happening after the client receives the data?
Jul 19 '05 #2
Server.URLEncode(TheString)

I'm pretty sure there's an HTMLEncode one aswell but, never had a need to
know so can't say for sure.

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Joeandtel <an*******@discussions.microsoft.com> wrote in message
news:A9**********************************@microsof t.com...
I have a form that asks for the size of a particular object. Sometimes the

size is 4" X 8". The problem that arises is when the record is pulled back
from a database to a textbox in a form; I get an error with HTML. I try and
place the 4" X 8" into a text box, like <input type="text" name="size"
value="4" X 8""> Is there something I can do in ASP to keep this from
happening after the client receives the data?
Jul 19 '05 #3
Joeandtel wrote:
I have a form that asks for the size of a particular object.
Sometimes the size is 4" X 8". The problem that arises is when the
record is pulled back from a database to a textbox in a form; I get
an error with HTML. I try and place the 4" X 8" into a text box, like
<input type="text" name="size" value="4" X 8""> Is there something I
can do in ASP to keep this from happening after the client receives
the data?


Double the quotes before writing the string into the value property. So it
looks like this:

<input type="text" name="size" value="4"" X 8""">

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #4
Are you feeling okay today Bob?

Ray at work

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:Ox**************@TK2MSFTNGP11.phx.gbl...
Double the quotes before writing the string into the value property. So it
looks like this:

<input type="text" name="size" value="4"" X 8""">

Jul 19 '05 #5
"Steven Burn" <nobody@PVT_it-mate.co.uk> wrote in message
news:Oq**************@TK2MSFTNGP09.phx.gbl...
Server.URLEncode(TheString)

I'm pretty sure there's an HTMLEncode one aswell but, never had a need to
know so can't say for sure.


As the name would suggest, URLEncode is for encoding URL values, and
HTMLEncode is for encoding regular HTML. They are different, so don't try
to use URLEncode as a catch all. For example:
<%
' Double the quotes to put a double quote in the string value
val = "4"" X 8"""
%>
<input type="text" name="size" value="<%=Server.HTMLEncode(val)%>">
<input type="text" name="size" value="<%=Server.URLEncode(val)%>">

The output above will look like this:

<input type="text" name="size" value="4&quot; X 8&quot;">
<input type="text" name="size" value="4%22+X+8%22">

Note, the first one will look correct in browsers... the 2nd will not.

Regards,
Peter Foti

Jul 19 '05 #6
Guess I had a brain fart.
Of course doubling the quotes won't wotk. This is HTML, not vbscript ...

However, using apostrophes for delimiters WILL work:
<input type="text" name="size" value='4" X 8"'>

Bob Barrows

Ray at <%=sLocation%> [MVP] wrote:
Are you feeling okay today Bob?

Ray at work

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:Ox**************@TK2MSFTNGP11.phx.gbl...
Double the quotes before writing the string into the value property.
So it looks like this:

<input type="text" name="size" value="4"" X 8""">


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #7
hehe, slight screwup on my part ;o)

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Peter Foti <pe***@Idontwantnostinkingemailfromyou.com> wrote in message
news:10*************@corp.supernews.com...
"Steven Burn" <nobody@PVT_it-mate.co.uk> wrote in message
news:Oq**************@TK2MSFTNGP09.phx.gbl...
Server.URLEncode(TheString)

I'm pretty sure there's an HTMLEncode one aswell but, never had a need to know so can't say for sure.


As the name would suggest, URLEncode is for encoding URL values, and
HTMLEncode is for encoding regular HTML. They are different, so don't try
to use URLEncode as a catch all. For example:
<%
' Double the quotes to put a double quote in the string value
val = "4"" X 8"""
%>
<input type="text" name="size" value="<%=Server.HTMLEncode(val)%>">
<input type="text" name="size" value="<%=Server.URLEncode(val)%>">

The output above will look like this:

<input type="text" name="size" value="4&quot; X 8&quot;">
<input type="text" name="size" value="4%22+X+8%22">

Note, the first one will look correct in browsers... the 2nd will not.

Regards,
Peter Foti

Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: lawrence | last post by:
A user writes this sentence: "It was the New Urbanist's nightmare of sprawl run amok." They input that and my PHP script hits it with addslashes() and then the sentence gets put in the database....
2
by: Jon Maz | last post by:
Hi, I have written a page to test a function of mine that strips non-English accents and various other characters out of a given string. The function itself (called 'StripAll' in the code below)...
9
by: Abdul Azeem | last post by:
Hi All I have some data string like ~!@#$%'^&(*("}[;asd"> which contains double quote and greater then sign, first I need to insert this value into database, second this inserted value I have...
24
by: deko | last post by:
I'm trying to log error messages and sometimes (no telling when or where) the message contains a string with double quotes. Is there a way get the query to insert the string with the double...
3
by: REB | last post by:
I have a button that executes this sql query: sqlcmdInsertPhysicalNote.CommandText = "INSERT INTO DriverPhysicalNotes (DriverInformationID, PhysicalNoteDate, PhysicalNote) VALUES ('" +...
7
by: gar | last post by:
Hi, I need to replace all the double quotes (") in a textbox with single quotes ('). I used this code text= Replace(text, """", "'" This works fine (for normal double quotes).The problem...
3
by: Solution Seeker | last post by:
I want to Store the String value with Single Quotes in the Field of Database where if i try to Store the String value with Single Quotes (as it is) then it is throwing the error as SQL String...
4
by: Justin Fancy | last post by:
Hi everyone, I need to replace all instances of a double quote(") with two single quotes('') in a text file. I already have some replacements of strings going on, but I tried this one, but the...
7
by: nick.bonadies | last post by:
I'm trying to deal with user inputs of single quotes into form fields that get input into a MSSQL database. So far I have discovered that if I turn on magic_quotes_sybase in my php.ini file PHP...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.