469,890 Members | 1,425 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,890 developers. It's quick & easy.

ASP - HTML not recognising line break

I am posting data to a sql server database via an asp web form. When
retreiving the data the information is all concatenated on one line
i.e.
When posting in textarea the format looks like:

1. information
2. information
3. information

but when retreiving the data it looks like:

1. information2. information3. information

I am storing the data in type ntext and when i look in the database
the data is correctly formated on seperate lines. Can anyone help ?
Jul 20 '05 #1
3 9101
stuart wrote:
I am posting data to a sql server database via an asp web form. When
retreiving the data the information is all concatenated on one line
i.e.
When posting in textarea the format looks like:

1. information
2. information
3. information

but when retreiving the data it looks like:

1. information2. information3. information

I am storing the data in type ntext and when i look in the database
the data is correctly formated on seperate lines. Can anyone help ?


browsers will concatenate whitespace. experiment with formating. perhaps
start with: convert cr/lf to <br>

--
William Tasso - http://WilliamTasso.com
Jul 20 '05 #2
st*************@kellogg.com (stuart) wrote:
I am posting data to a sql server database via an asp web form. When
retreiving the data the information is all concatenated on one line
i.e.
When posting in textarea the format looks like:

1. information
2. information
3. information

but when retreiving the data it looks like:

1. information2. information3. information


Yes, the same result that you would get if you had typed

1. information
2. information
3. information

directly into a static web page in a text editor. HTML treats new-line
characters as white space, not as new lines. To produce a line break
in HTML, you use the <br> tag. So if you want to display data that
contains new-line characters in HTML, and you want the line breaks to
appear in the browser, you need to replace them with "<br>":

Response.Write Replace(myText, chr(13) & chr(10), "<br>")
--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ôter le premier point de mon adresse de courriel.
Jul 20 '05 #3
On Thu, 15 Jan 2004, stuart wrote:
I am posting data to a sql server database via an asp web form. When
retreiving the data the information is all concatenated on one line
i.e.
When posting in textarea the format looks like:

1. information
2. information
3. information

but when retreiving the data it looks like:

1. information2. information3. information
I don't believe that the _data_ looks like that. Maybe that's what
you're seeing after the data has been erroneously processed as if it
were HTML.

Your chief problem here is that you've got so many complicating
factors in your problem that you've lost touch with reality. Suppose
that you coded an HTML source like that:

1. information
2. information
3. information

without any HTML markup, and then fed it to a browser. What would you
expect to see?
when i look in the database the data is correctly formated


But with respect, since you seem to be confused about what is
"correct", I think we need to be told just exactly what you found
there, rather than merely that you considered it to be "correct".

Textarea submission is defined to include the newlines that were
contained in the submitted data. Based on what you're reporting as
input, it appears that you are in fact submitting newlines. Those
newlines, if sent to a browser, *ought* to be treated as white space.
If that was the case, then I would expect to see:

1. information 2. information 3. information

which is different from what you're reporting.

Finally, don't forget to tell us what it is that you're trying to
achieve. Is the user supposed to be supplying HTML markup into the
text area, or are they supposed to be supplying plain-text and your
software is supposed to be applying appropriate markups to that?

good luck
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by IceOnFire | last post: by
30 posts views Thread by just say NO to PDF | last post: by
4 posts views Thread by Rick | last post: by
9 posts views Thread by MW de Jager | last post: by
10 posts views Thread by Eric Lindsay | last post: by
23 posts views Thread by andrew | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.