Line breaks in HTML code

M

mailbox

Did write it down once, but have forgotten !!

How is it you should format your ASP code to that when viewing the resulting
HTML text from the browsers "view code" it looks nice with line breaks?
 
A

Adrienne

Did write it down once, but have forgotten !!

How is it you should format your ASP code to that when viewing the
resulting HTML text from the browsers "view code" it looks nice with
line breaks?

You can escape from ASP eg:
<% 'your asp code here%>
<p>This is the result of <%=variable%></p>
<% 'more code%>
<p>This is another result of <%=anothervariable%></p>

Or:
<% text = "some text" & vbcrlf
text = text & "more text"
response.write replace(text,vbcrlf,"<br>")
%>
 
P

please-answer-here

Adrienne said:
You can escape from ASP eg:
<% 'your asp code here%>
<p>This is the result of <%=variable%></p>
<% 'more code%>
<p>This is another result of <%=anothervariable%></p>

It's not the resulting HTML page I'm having problem with. What I would like
to implement is that when you after loading the asp page, would like to view
the HTML source code that code would be layouted with line breaks
 
R

Roland Hall

in message
: Adrienne wrote:
: > Gazing into my crystal ball I observed "mailbox"
: > <[email protected]> writing in
: > : >
: >> Did write it down once, but have forgotten !!
: >>
: >> How is it you should format your ASP code to that when viewing the
: >> resulting HTML text from the browsers "view code" it looks nice with
: >> line breaks?
: >>
: >>
: >>
: >
: > You can escape from ASP eg:
: > <% 'your asp code here%>
: > <p>This is the result of <%=variable%></p>
: > <% 'more code%>
: > <p>This is another result of <%=anothervariable%></p>
:
: It's not the resulting HTML page I'm having problem with. What I would
like
: to implement is that when you after loading the asp page, would like to
view
: the HTML source code that code would be layouted with line breaks

It's vbCrLf. You will only see the line breaks in the source, not displayed
in the browser. That requires <br />.

I use:

sub prt(str)
Response.Write str & vbCrLf
end sub

I use it for generally anything with a tag...
prt "<html>"
prt "<head>"
prt "</head>"

You can use them together as Adrienne showed...

sub lprt(str)
Response.Write str & "<br />" & vbCrLf
end sub

I use it for anything without a tag where I was a line break displayed in
the browser...

lprt "Error: The field cannot be left blank."

You can even use it for a blank line...

lprt ""

sub wprt(str)
Response.Write str
end sub

I use it for when I want to print but not end the line...

prt "<table>"
wprt "<tr><td>" & someVariable & "</td>"
' do some processing...
wprt "<td>" & addAnotherVariable & "</td>"
' do some more processing
prt "<td>" & andAnother & "</td></tr>"
prt "</table>"

sub debug(str)
Response.Write "<span style=""background-color: #efe"">" & str & "<br
/>" & vbCrLf
end sub

This one should be obvious...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
H

Hal Rosser

mailbox said:
Did write it down once, but have forgotten !!

How is it you should format your ASP code to that when viewing the resulting
HTML text from the browsers "view code" it looks nice with line breaks?

If you just want your 'view source' to look good
use VBCrLf to include the newline characters
 
P

please-answer-here

Hal said:
If you just want your 'view source' to look good
use VBCrLf to include the newline characters

Thanks to everyone for refreshing my memory
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top