I have data (text + CR + LF) stored in SQL Server 6.5 as a TEXT data type. When I want to display the data on an ASP page, the text loses its format. If I use TEXT INPUT on my ASP, it works fine but I need to scroll up and down to see the data, which is okay, but when I print, not all the data gets printed.
Do you have a workaround for this problem? I am trying to reduce the maintenance of one of our sites, which has hundreds of similar HTML pages that could be generated by one ASP page.
The data is being presented correctly within your ASP/HTML page. If you choose to View Source, you will see that all your line breaks CR+LFs are being retained. However, one of the rules of HTML rendering is that it ignores extra white space. So your line breaks are being ignored. Therefore, you are losing the format.
To fix this problem, before you write the data out to the browser (using a Response.write), replace all occurrences of the CR+LF with the HTML equivalent,
. Assuming strText contains the value you want to write to the browser, use the code:
Response.write Replace(strText, vbCrLf, "
The vbCrLf is a built-in constant for the CR+LF characters.