ASP Line-breaks - \n?

Coughlin picture Coughlin · Dec 14, 2008 · Viewed 54.9k times · Source

I have been searching for a way to insert linebreaks in my code for when I view my source. I am not looking for <br />

Something like the PHP equiv to \n

Any ideas on how to do this in ASP? I will be placing this inside a string.

Answer

John Sheehan picture John Sheehan · Dec 14, 2008

There's no way to do it inside a string. You will have to append vbCrLf like so:

Response.Write "hello" & vbCrLf & "world"

If you want to include it in the string, you could do a replace after like so:

output = "hello\nworld"
output = Replace(output, "\n", vbCrLf)
Response.Write output