Print Page | Close Window

New lines

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=747
Printed Date: 29 March 2026 at 2:55am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: New lines
Posted By: Scott07
Subject: New lines
Date Posted: 05 March 2003 at 9:43am

How do you make it so that you have a normal <TEXTAREA> box and the code will check to see if there are any new lines (as in

 

this).  What I am trying to get it to do is to convert all the HTML codes as in <,> ect into the & codes so people cant write HTML code but keep the new lines so if they put more than one paragraph in the spacing isent lost.  How you get what I am battering on about. 

 

Any help would be much appriciated, thanks. 



-------------
http://www.worldsofwar.co.uk - Worlds of War II



Replies:
Posted By: MorningZ
Date Posted: 05 March 2003 at 11:28am
are you letting people do <p></p> and <br> and <br /> (and also <br/>), or are you just trying to catch when they hit "enter" (creating a vbCrlf in the data), or both?

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Scott07
Date Posted: 05 March 2003 at 2:28pm
so it only reconises when someone hits return but will reject <BR>

-------------
http://www.worldsofwar.co.uk - Worlds of War II


Posted By: MorningZ
Date Posted: 05 March 2003 at 4:05pm
then there's two avenues you can take, with difference in the front end processing and resultant storage, but the same on display

1)
- Server.HTMLEncode the textarea's contents on the way in, all "returns" entered in the textarea are "vbCrlf"'s not <br> tags, so the encoding will leave the line breaks alone
- On the way to display, Replace(string,vbCrlf,"<br>") and line breaks work, but enterted HTML doesn't

2) (and the way i do/recommend it)
- Simply save the contents of the entered text (of course escaping the signle tics if needed)
- On the way out, do the Server.HTMLEncode on the field, then afterwards do a Replace(string,vbCrlf,"<br>")
- Since the replace of the line breaks happens after the encoding, the <br> tag will properly evaluate, while all user types HTML tags get "escaped" and show <tag>

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: MorningZ
Date Posted: 05 March 2003 at 4:15pm
a la

http://www.morningz.com/sections/playground/files/code/lineBreaks.asp - this example i threw together for ya

-------------
Contribute to the working anarchy we fondly call the Internet



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net