Many friends don't know much about the implementation of ASP line breaks, and they don't know what code to use under what circumstances. Here Script Home will briefly explain it to you, hoping it can be helpful to everyone.
Test code: output simple ul li
1.asp
Copy the code code as follows:
<%
response.write "<ul>"
response.write "<li>Script Home</li>"
response.write "<li></li>"
response.write "</ul>"
%>
The result is: right-click the source file and see the following
Copy the code code as follows:
<ul><li>Script Home</li><li></li></ul>
1. If you want the characters to look good in the source file and to optimize reading, you can use vbcrlf
The code is written as
Copy the code code as follows:
<%
response.write "<ul>"&vbcrlf
response.write "<li>Script Home</li>"&vbcrlf
response.write "<li></li>"&vbcrlf
response.write "</ul>"
%>
The output source code is
Copy the code code as follows:
<ul>
<li>Script Home</li>
<li></li>
</ul>
The second type: if it is an ordinary file, it can be used in the middle
Copy the code code as follows:
response.write "<div>Script Home<br></div>"
The third type: If it is to be displayed alternately in textarea and html, then
In this case, content is generally submitted through textarea rather than web page editing, so you need to replace the line break of textarea with <br>
CHR(10) means line feed, CHR(13) means carriage return
The newline character in asp can be used with the constant: vbcrlf and the function: chr(13);
Copy the code code as follows:
response.write "Login successful"&vbcrlf&"Welcome"
content=replace(content,"vbcrlf","<br>") -
The following is to replace the newline in the textarea with <br>
Copy the code code as follows:
fString = Replace(fString, CHR(10), "<br>")
fString = Replace(fString, CHR(13), "<br>")
If it's the other way around, the br line breaks in html need to be replaced with the line breaks in textarea.
Copy the code code as follows:
fString = Replace(fString, <br>, vbcrlf)
I won’t write the more specific details. You can test it by yourself. The program is tested while writing. It's not obvious.
Other opinions
When I was writing an ASP program recently, I wanted my HTML code to be output directly in ASP, and I also asked him to output it in a very neat format. I tried the long-used tab symbols /n and /t that I have written about for a long time, but they could not be output directly. So Diplodocus checked the relevant information on Baidu and posted it to let people pay attention to Diplodocus and Diplodocus. Blog friends can gain knowledge accumulation from it. When Diplodocus was learning ASP before, he didn't seem to pay much attention to this, but now he is trying to make up for it. Okay, let’s go straight to the above
vbCr Chr(13) carriage return character.
vbCrLf Chr(13) & Chr(10) carriage return and line feed characters.