Displaying Saved Line Feeds/Carriage Returns

When displaying the information contained in and/or saved in a database from a Multiline textbox, remember, it saves line feeds/carriage returns as just that – line feeds/carriage returns.

A web browser does not recognize those characters – - therefore, to display them as such, you must replace the characters with tags a web browser can understand, like <br> or <p>.

In VB.Net, ‘vbcrlf’ is the equivalent of a LineFeed/CarriageReturn, so to display those correctly in a browser, before displaying them (lets call the string, ‘sItem’), you need to do something like this:

sItem=sItem.Replace(vbcrlf, “<br>”)

.Then, when sItem (a variable containing the saved data) is displayed, it will display correctly.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>