This topic is locked

Carriage returns not displaying in list page

8/21/2003 2:09:42 PM
ASPRunnerPro General questions
J
John F author

When a user enter text into a form and the 'textarea' box is used. If the entry contains a 'carriage return' in the form field, the 'carriage return' does not show up in the list.asp code and the whole entry becomes one continues piece of text.
Is there a way of ensuring the 'carriage return' entered into the form field to separate paragraphs of text are diplayed as carriege returns in the list.asp output.
I use a MYSQL database and am posting the contents of the 'textarea' field to a 'text' field type.
Thanks
John F

Sergey Kornilov admin 8/22/2003

John,
you have two options here:

  1. You can use MySQL's REPLACE function to get your text formatted correctly. On "Edit SQL query manually" page edit your SQL query this way:

select

...

replace(textfield, "\n", "<br><br>") as newtextfield

from <Tablename>


2. On the ..._list.asp page find a place where this field display and change it to something like this:

Response.Write Replace(GetData(rsData.Fields("FieldName"), ""), vbCrLf, "<br><br>")


I hope this helps.
Sergey Kornilov

Support team

R
rgke 7/19/2006

I am using SQL 2000, and have tried to use the second solution offered here. However, now my text is displayed as Line1<BR><BR>Line2<BR><BR> etc
What I am doing wrong? Also, with this solution, do I have to reapply this everytime I rebuild the pages?

J
Jane 7/20/2006

Hi,
select HTML for your field in the View as dropdown box on the Formatting tab.

R
rgke 7/20/2006

OK, that's fixed the <BR> visible problem. Now, is it possible to retain the replace code so that it does not lose it everytime I rebuild the pages?

J
Jane 7/20/2006

All changes in the generated files are removed after rebuild.

To save your changes you can edit templates in the Template Editor on the Misceelaneous tab.