By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,623 Members | 1,301 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,623 IT Pros & Developers. It's quick & easy.

ASP - HTML not recognising line break

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.