We often need to dynamically display the content retrieved from files on webpages. If you have compiled a program such as a chat room or forum, the content of each speaker must first exist in a text file and then be displayed on the webpage. However, the control that allows users to input content on the webpage is a text box. When the content in the text box is displayed on the webpage, characters similar to spaces and line breaks cannot be displayed, that is, there is no paragraph. To display paragraphs on a webpage, you must insert HTML characters in the spaces and line breaks of the text to display these characters. See the following example.
If a chat room screen is displayed on the webpage, we enter the content in the text box and click "Submit" to display our content on the page. The text box is named text1, we can use the following method to skillfully display text line breaks and spaces.
<%
......
......
STR = request. querystring ("text1 ")
STR = Replace (STR, CHR (32), "& nbsp ")
'Change the space to the & nbsp flag.
STR = Replace (STR, vbcrlf, "<br> ")
'Change the carriage return line break to the <br> flag.
Response. Write Str
......
......
%>
After the above Code, we will change the line breaks in the text to the line breaks that the browser can recognize, and replace the spaces with the & nbsp spaces. CHR (32) indicates space, while vbcrlf indicates carriage return and line feed.