Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New Line

Status
Not open for further replies.

Alruk

Technical User
Mar 16, 2004
25
GB
I am very new to .asp, and ive wrote basic static pages in the past. BUT I have an OCD for keeping the code tidy and readable.

Ive used the response.write function, but find the final html code is very untidy and hard to read/check for errors.

Can you force a new line in the pages source html code, to make viewing easier/checking for errors easier?

Any help much appreciated.
 
Try the <br> tag wherever you want to insert a new line in HTML.

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
i believe he's referring to the source..not output...if so...
Code:
 <%
   ' if you do not use the vbCrlf (& _), for example,
   ' then it's used as a simple line continuation 
   ' vs carriage AND line

   Response.Write vbCrlf & _
                  "<table border=""1"" width=""200"">" & vbCrlf & _
                  " <tr>" & vbCrlf & _
                  "  <td>Today's Date:</td>" & vbCrlf & _
                  "  <td>" & Date() & "</td>" & vbCrlf & _
                  " </tr>" & vbCrlf & _
                  "</table>" & vbCrlf
%>
 
Hi, Thanks for your replies.

Ive tried both of these and neither seem to be what Im looking for. I think its the way I explanied.

I think I am referring to the output rather than the source. Ive included an exampled an example below.

If I run a code similar to below:

Do While not rslistitem.EOF

response.write("<li>")
response.write('"&rslistitem("listdata")&"')
response.write("<li/>")

rslistitem.MoveNext

Loop

It outputs :

li>List Item 1<li/><li>List Item 2<li/><li>List Item 3<li/><li>List Item 4<li/><li>List Item 5<li/>

I want it to output:

<li>List Item 1<li/>
<li>List Item 2<li/>
<li>List Item 3<li/>
<li>List Item 4<li/>
<li>List Item 5<li/>

Hope this makes more sense.

 
Try:
Code:
Do While not rslistitem.EOF

response.write("<li>")
response.write('"&rslistitem("listdata")&"')
response.write("<li/>" [COLOR=red]& vbCrLf[/color])

rslistitem.MoveNext
 
Thats Great

Thanks for your help

 
just remember when you are trying to generate what the user see's (client) as html source code ,(generated by server), to put vbCrlf on the lines you want to return down...the example provided earlier was for a table...and the OCD would be a little more vs a simple list...i hope that makes sense...also...

save a little strain on yourself and the server by using line continuations vs multiple response.writes(each response.write is a hit)

ie:
btw: i would typically put on one line(your example)...it was simply for demo(line continuation) purposes
Code:
<%
  Response.Write "<li>" & _
                    rslistitem("listdata") & _
                 "</li>" & vbCrlf
%>

glad you got it sorted out :)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top