[thelist] content templates with ASP and SQL - converting hard returns to <p></p>

Wade Armstrong wade at runstrong.com
Mon Jan 21 17:53:31 CST 2002


It's the first one. Actually, I'd do it the other way around -
strText = Replace(strText, vbNewLine, "</p><p>") 'Replace every new line
with a close para and then open a new para
strText = Replace(strText, vbCrLf, "<br />") 'Replace every line break with
a <br />
strText = "<p>" & strText & </p> ' The first replace will leave you without
an opening <p> and a closing </p>

To make life easier on yourself, run this replace when you display the data,
not when you enter it into the DB. Why? If you want to edit the content
again, or repurpose it for some entirely different use, having the raw input
will be a lot easier to work with than input interspersed with a lot of HTML
code - especially if you allow the user to enter some HTML manually.

Wade

on 1/21/02 9:55 AM, David Mitchell at David at softv.net wrote:

> strText = Replace(strInput, vbCrLf, "<p></p>")
> or//
> strText = Replace(strInput, "\n", "<p></p>")
> 
> Can't remember which one of those will work...one should ;-)
> 





More information about the thelist mailing list