473,324 Members | 2,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

ASP or HTML in asp file

I am just curious as to when it is better to use straight HTML or ASP
(response.write) to put out HTML code on an ASP page.

For example, if I have an ASP page that is including another ASP page,
but the rest of the code is just HTML, which is the better way to do it.

Here is my example:

The file I am including in my ASP file (banner.asp).
************************************************** ****************
<%
Response.Write("<P>Welcome to my Web site! ")
Response.Write("The time of your visit is " & Time &"<BR>")
%>
************************************************** ****************

The ASP file that is including this file can be done one of 2 ways. The
first way displays the HTML code as response.writes:
************************************************** ***************
<HTML>
<HEAD>
<TITLE>Ultimate Parenting Resource</TITLE>
</HEAD>
<BODY>

<%
Response.Write("<H1>The Ultimate Parenting Resource</H1>")

Server.Execute("banner.asp")

Response.Write("<BR>You can browse this Web site to find ")
Response.Write("information concerning everything from ")
Response.Write("bathing baby to buying the perfect prom ")
Response.Write("outfit for your teenager!")

%>

<P>
Thank-you for visiting The Ultimate Parenting Resource.

</BODY>
</HTML>
************************************************** ***************

The other way just uses ASP code for the Server.Execute statement and
puts all the rest as straight HTML code:
************************************************** *****************
<HTML>
<HEAD>
<TITLE>Ultimate Parenting Resource</TITLE>
</HEAD>
<BODY>

<H1>The Ultimate Parenting Resource</H1>

<%
Server.Execute("banner.asp")
%>

<BR>You can browse this Web site to find
information concerning everything from
bathing baby to buying the perfect prom
outfit for your teenager!

<P>
Thank-you for visiting The Ultimate Parenting Resource.

</BODY>
</HTML>
************************************************** ****************

The result is the same page. Is one way better than the other? If so, why?

Thanks,

Tom.

Jul 19 '05 #1
4 1557
"Thomas Scheiderich" <tf*@deltanet.com> wrote in message
news:40**************@deltanet.com...
I am just curious as to when it is better to use straight HTML or ASP
(response.write) to put out HTML code on an ASP page.

The result is the same page. Is one way better than the other? If so,

why?

I find that I make these decisions based on whatever makes more sense
logically as I am making the pages. I'm not going to spend 15 lines
Response.Writing some HTML. I'll just close my ASP tag and write regular
HTML. If I have a page that is 99% HTML but has a lot of ASP code that does
nothing but process data and perhaps return a value or two for the HTML
page, then I will put that ASP code in a separate file, encapsulate things
in functions, use <%=FunctionName%> in my mostly-HTML asp file and then
include the file with the code.

Ray at home
Jul 19 '05 #2
Ray at <%=sLocation%> [MVP] wrote:
"Thomas Scheiderich" <tf*@deltanet.com> wrote in message
news:40**************@deltanet.com...
I am just curious as to when it is better to use straight HTML or ASP
(response.write) to put out HTML code on an ASP page.

The result is the same page. Is one way better than the other? If so,
why?

I find that I make these decisions based on whatever makes more sense
logically as I am making the pages. I'm not going to spend 15 lines
Response.Writing some HTML. I'll just close my ASP tag and write regular
HTML. If I have a page that is 99% HTML but has a lot of ASP code that does
nothing but process data and perhaps return a value or two for the HTML
page, then I will put that ASP code in a separate file, encapsulate things
in functions, use <%=FunctionName%> in my mostly-HTML asp file and then
include the file with the code.

So you would do the second file where the only asp code would be the
Server.Execute.

That made the most sense to me. I just wanted to make sure I wasn't
missing something, like maybe switching back and forth between ASP tags
was inefficient or something.

Thanks,

Tom.

Ray at home


Jul 19 '05 #3

"Thomas Scheiderich" <tf*@deltanet.com> wrote in message
news:40**************@deltanet.com...

So you would do the second file where the only asp code would be the
Server.Execute.
I wouldn't create a file that had only one line in it of server.execute. I
break files apart based on the re-usability of the code it uses, typically.
Many of my pages do not have their own ASP code in them aside from inline
<%=functionName|ConstantName%> or <% Call SubRoutineThatWritesHTML %>. Any
time I find that I would be re-writing the same code in two places, that
goes in an include.
That made the most sense to me. I just wanted to make sure I wasn't
missing something, like maybe switching back and forth between ASP tags
was inefficient or something.


I believe there's a performance penalty in switching in and out of <% %>
throughout your page if you're on an NT4 server with <= IIS4. From things
I've read, this is NOT the case in >= II5. So, code the way that you're
comfortable! I think you'll find that you'll change your methods as you do
more projects. When I go back and look at my coding practices in my first
ASP project, I get embarrassed in front of myself. :]

Ray at work
Jul 19 '05 #4
Ray at <%=sLocation%> [MVP] wrote:
"Thomas Scheiderich" <tf*@deltanet.com> wrote in message
news:40**************@deltanet.com...
So you would do the second file where the only asp code would be the
Server.Execute.

I wouldn't create a file that had only one line in it of server.execute.

So if you were to write the page I had, and assuming that the 2 lines of
ASP code were going to reused in 4 or 5 other pages, how would you
display this page.

I would assume that if this were only used once you would just type the
ASP code directly into the page.

I break files apart based on the re-usability of the code it uses, typically.
Many of my pages do not have their own ASP code in them aside from inline
<%=functionName|ConstantName%> or <% Call SubRoutineThatWritesHTML %>. Any
time I find that I would be re-writing the same code in two places, that
goes in an include.

An include vs the Server.Execute? Not really sure when I would use one
over the other.


That made the most sense to me. I just wanted to make sure I wasn't
missing something, like maybe switching back and forth between ASP tags
was inefficient or something.

I believe there's a performance penalty in switching in and out of <% %>
throughout your page if you're on an NT4 server with <= IIS4. From things
I've read, this is NOT the case in >= II5. So, code the way that you're
comfortable! I think you'll find that you'll change your methods as you do
more projects. When I go back and look at my coding practices in my first
ASP project, I get embarrassed in front of myself. :]

I agree. I have been programming for many years and whenever I look at
my old code, especially if I am going to reuse some of it, I find myself
rewritting it.

Tom


Ray at work


Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Sherry Littletree | last post by:
Hi All I am working on a site that has a large amount of common html on all its web pages. I am looking for a way to place this in a single file so, if changes are made, I can change this...
0
by: a | last post by:
Save text file as html kloepper 17:42 23 Jul '04 I'm using httpwebresponse and a StringBuilder to return a stream that originates as a file with the .txt suffix (My download code converts the html...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
59
by: Lennart Björk | last post by:
Hi All, I have a tiny program: <!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>MyTitle</title> <meta...
3
by: Chuck Renner | last post by:
Please help! This MIGHT even be a bug in PHP! I'll provide version numbers and site specific information (browser, OS, and kernel versions) if others cannot reproduce this problem. I'm...
8
by: rn5a | last post by:
I have a HTML page named Index.html which is divided into 3 frames. The URL of 2 of the frames are HTML pages but the 3rd frame houses a ASP page. Now when I go to Windows Explorer, navigate to...
15
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to...
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
42
by: Santander | last post by:
how to decode HTML pages encoded like this: http://www.long2consulting.com/seeinaction2008/Simplicity_Beach_table/index.htm Is there script that will do this automatically and generate normal fully...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.