ASP Is Fun

Learning ASP
Free Course
Basics
Functions
SQL Commands
Sample Code

Servers / Setup
Host Reviews
Server Setup
Error Tips

Contract ASP
Development

Intro to ASP



 
French Wedding


Formatting Text for HTML Display



A common task in ASP is to take a block of text from a database or user input, and put it on a webpage to be read. Make sure that you format it nicely!

Let's say you use either a SQL statement or a request from a form to get the value

UserComments

Let's say that UserComments is a long, long description that some user typed in about your product or website or favorite movie. Now you have this long description and want to show it on a browser page.

If you just say

response.write UserComments

you are going to get a GIANT block of text, all mashed together. That isn't going to be readable at all! Remember, HTML ignores simple hard returns. So all of that line break and paragraph break content that your user typed in will be lost.

Instead, use the REPLACE function to turn those line breaks into <BR> commands. HTML uses BR to determine when to move to the next line.

So the command would be

UserComments = Replace(UserComments, CHR(13), "<BR>")

Now all of those line breaks have been turned into actual BR entries. Your browser will then put line breaks in at those spots, and the content becomes nicely readable to your end users!

ASP Text Parsing Code


ASP Main Page | ASP Ebooks | Free ASP Course | Contact Lisa
All content copyright © 2008 Minerva WebWorks LLC. All rights reserved.

French Wedding


Free Newsletter!

Ebooks
Intro to ASP
ASP SQL DB
Members
Shopping


Introduction to ASP

Romance Tips
Irish Romance
Italian Romance
French Romance

ASP Poll
How do you handle 500 errors?
I don't
Page does nothing
Displays error
Emails error