Is it inefficient to intermix HTML and script?

S

Stefan Berglund

I've noticed that most examples offered in this group tend to use Response.Write to spit out the HTML rather than switch between
script and HTML. I also came across an article intimating the same idea. Is this considered inefficient?

<%If (IsArray(ar)) Then
Const cNumber = 0
Const cHorse = 1
Const cOwner = 2
Const cTrainer = 3
Const cRider = 4
Const cHorseID = 5
Const cOwnerID = 6
Const cTrainerID = 7
Const cRiderID = 8%>
<tr>
<th width="8%" align="center"><a class="results" href="showshowentries.asp?Show=<%= strShowID%>&Sort=Number"><font face="Arial, Helvetica, sans-serif" size="2"><b>Number</b></font></a></th>
<th width="23%" align="left"><a class="results" href="showshowentries.asp?Show=<%= strShowID%>&Sort=Horse"><font face="Arial, Helvetica, sans-serif" size="2"><b>Horse</b></font></a></th>
<th width="23%" align="left"><a class="results" href="showshowentries.asp?Show=<%= strShowID%>&Sort=Owner"><font face="Arial, Helvetica, sans-serif" size="2"><b>Owner</b></font></a></th>
<th width="23%" align="left"><a class="results" href="showshowentries.asp?Show=<%= strShowID%>&Sort=Trainer"><font face="Arial, Helvetica, sans-serif" size="2"><b>Trainer</b></font></a></th>
<th width="23%" align="left"><a class="results" href="showshowentries.asp?Show=<%= strShowID%>&Sort=Rider"><font face="Arial, Helvetica, sans-serif"
size="2"><b>Rider</b></font></a></th></tr>
<% Dim iRow
For iRow = 0 To UBound(ar,2)%>
<tr>
<td width="8%" align="center" valign="top"><font face="Arial, Helvetica, sans-serif" size="2"><%= ar(cNumber,iRow)%></font></td>
<td width="23%" align="left" valign="top"><a class="results" href="showexhibitorresults.asp?Show=<%= strShowID%>&HorseID=<%= ar(cHorseID,iRow)%>"><font face="Arial, Helvetica, sans-serif"
size="2"><%= ar(cHorse,iRow)%></font></a></td>
<td width="23%" align="left" valign="top"><a class="results" href="showexhibitorresults.asp?Show=<%= strShowID%>&OwnerID=<%= ar(cOwnerID,iRow)%>"><font face="Arial, Helvetica, sans-serif"
size="2"><%= ar(cOwner,iRow)%></font></a></td>
<td width="23%" align="left" valign="top"><a class="results" href="showexhibitorresults.asp?Show=<%= strShowID%>&TrainerID=<%= ar(cTrainerID,iRow)%>"><font face="Arial, Helvetica,
sans-serif" size="2"><%= ar(cTrainer,iRow)%></font></a></td>
<td width="23%" align="left" valign="top"><a class="results" href="showexhibitorresults.asp?Show=<%= strShowID%>&RiderID=<%= ar(cRiderID,iRow)%>"><font face="Arial, Helvetica, sans-serif"
size="2"><%= ar(cRider,iRow)%></font></a></td></tr>
<% Next%>
<tr>
<td align="right" colspan="5"><font face="Arial, Helvetica, sans-serif" size="2"><b><%= intTotalEntries%> total show entries&nbsp;&nbsp;&nbsp;&nbsp;</b></font></td></tr>
<%Else%>
<tr>
<td colspan="5" align="center"><font face="Arial, Helvetica, sans-serif" size="2"><b>There are no items to show in this view.</b></font></td></tr>
<%End If%>
</table>
</td>
</tr>
<!--#include file="inc/table_end.asp" -->
 
A

Aaron Bertrand - MVP

I've noticed that most examples offered in this group tend to use
Response.Write to spit out the HTML rather than switch between
script and HTML. I also came across an article intimating the same idea.
Is this considered inefficient?

No, just much more difficult to read / maintain, IMHO. I prefer
response.write, but there really is no difference in performance due to
context switches between ASP and HTML (though at one point the ASP parser
wasn't as smart as it is now, and you would notice a hit given enough
volume).
 
R

Ray at

If you're running IIS 5 or higher, don't worry about it. Do whichever you
are more comfortable with. If you're on IIS 4 (NT), yeah, it's inefficient,
but hopefully you won't be on an NT server for much longer, so I wouldn't
worry about it. Just code comfortably. :]

Ray at work

Stefan Berglund said:
I've noticed that most examples offered in this group tend to use
Response.Write to spit out the HTML rather than switch between
script and HTML. I also came across an article intimating the same idea.
Is this considered inefficient?
 
J

Jeff Cochran

I've noticed that most examples offered in this group tend to use Response.Write to spit out the HTML rather than switch between
script and HTML. I also came across an article intimating the same idea. Is this considered inefficient?

For me it's force of habit and the method of coding. I tend to write
ASP in commented pseudocode to get the process down, then fill in the
bits and pieces testing as I go. Since I tend to do a lot of
Response.Write statements to show the output and values as I code,
when I get to the HTML I tend to leave the Response.Write alone and
fit in the HTML code into the Response.Write statements.

On the other hand, when I'm editing/maintaining someone else's code
that has the HTML separated and does things like:

<P>Glad to see you here on <% =(Now) %></P>

Then I tend to work in the same manner the original code is written.

Note that I am by far a sloppy coder, generally poorly organized and
bad at useful documentation, plus I tend to leave irrelevant code in
at times, but hey, it works. :)

Jeff
 
S

Stefan Berglund

On Mon, 20 Oct 2003 13:17:02 -0700, Stefan Berglund
in said:
I've noticed that most examples offered in this group tend to use Response.Write to spit out the HTML rather than switch between
script and HTML. I also came across an article intimating the same idea. Is this considered inefficient?

Thank you gentlemen one and all for your valued consideration and
comments.
 

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
474,132
Messages
2,570,775
Members
47,333
Latest member
DongPouncy

Latest Threads

Top