Page 250 - DCAP408_WEB_PROGRAMMING
P. 250
Web Programming
Notes To use the shortcut in the middle of a long block of ASP code would require that you first add a
closing %>, and then reopen with a <%=; close again with a %> and finally reopen with a <%.
!
Caution So many openings and closings of ASP code sections hurts the readability of your
code, besides, it may hurt the performance as well.
Therefore, it is a good practice to go ahead with the Response.Write.
Sometimes, when the script looks like this:
1: <%@Language=VBScript %>
2: <HTML>
3: <BODY>
4: Hello. My name is Joe. This is my page.
5: <P>
6: today is <%=date %>
7: </BODY>
8: </HTML>
If you had a long block of HTML where you needed a single line of output from the ASP, it
would probably be better to use the shortcut as is used in line 6; it is quite readable.
Using Response.Write in this case:
1: <%@ Language=VBScript %>
2: <HTML>
3: <BODY>
4: Hello. My name is Joe. This is my page.
5: <P>
6: today is
7: <%
8: Response.Write (Date)
9: %>
10: </BODY>
11: </HTML>
Response.Write is used in line 8. It is a little less readable.
Buffering ASP Pages
Besides sending output to the client, Response can control how and when the output is sent to the
client. Output can be sent in two different ways: buffered or unbuffered.
Unbuffered output is sent immediately.
Buffered output is not sent until the script is finished, or until a special command is given to send
it. For example, let’s say that you have a script with one Response.Write at the top and another
244 LOVELY PROFESSIONAL UNIVERSITY