Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 10:59 AM
Andrew
Guest
 
Posts: n/a
Default printing large blocks of HTML in ASP

I am making a web site and I am using ASP because of its templating
capabilities. My footer is an include file, for obvious reasons. I
can't use an include file for the header, because, while the top of
the page will be 90% similar, they will have different titles, page
titles, and left nav menus. I could write a function so that these
vars can be interpolated, except I don't want 70 lines of
Response.Write("foo") (there is a moderate amount of formatting on
each page). Does ASP have a "print HERE" function like Perl that
prints out large blocks of HTML and interpolates variables?

print <<<;
<html>
<head><title> strPageTitle </title>
<meta description="This site is an online for all those interested
in..">
</head>
<body bgcolor="wheat" leftmargin="0" link="blue" vlink="blue">
<center>
<table width="600" bgcolor="white">
<tr><td colspan="3" height="10">&nbsp;</td></tr>
<tr>
<td valign="top">
strMainLeftNav
</td>
<td width="10">&nbsp;</td>
<td><center> strPAgeTitle </center>
<p>
<table><tr><td>
<<<
  #2  
Old July 19th, 2005, 10:59 AM
David C. Holley
Guest
 
Posts: n/a
Default Re: printing large blocks of HTML in ASP

ASP can be used in this manner....

<% if a=1 then %>
Greetings World, we come in peace.
<% else %>
Greetings World, we come to conquer.
<% end if %>

Anything between the ASP blocks would be sent to the client as is. I
think that this is what you're looking for.

David H.
(Been thinking about "V" and "V-The Final Battle" recently)

Andrew wrote:[color=blue]
> I am making a web site and I am using ASP because of its templating
> capabilities. My footer is an include file, for obvious reasons. I
> can't use an include file for the header, because, while the top of
> the page will be 90% similar, they will have different titles, page
> titles, and left nav menus. I could write a function so that these
> vars can be interpolated, except I don't want 70 lines of
> Response.Write("foo") (there is a moderate amount of formatting on
> each page). Does ASP have a "print HERE" function like Perl that
> prints out large blocks of HTML and interpolates variables?
>
> print <<<;
> <html>
> <head><title> strPageTitle </title>
> <meta description="This site is an online for all those interested
> in..">
> </head>
> <body bgcolor="wheat" leftmargin="0" link="blue" vlink="blue">
> <center>
> <table width="600" bgcolor="white">
> <tr><td colspan="3" height="10">&nbsp;</td></tr>
> <tr>
> <td valign="top">
> strMainLeftNav
> </td>
> <td width="10">&nbsp;</td>
> <td><center> strPAgeTitle </center>
> <p>
> <table><tr><td>
> <<<[/color]

  #3  
Old July 19th, 2005, 11:00 AM
Andrew
Guest
 
Posts: n/a
Default Re: printing large blocks of HTML in ASP

I just counted, and the top of my web page is 169 lines of HTML and
DHTML.

My question was really about printing out large blocks of HTML in ASP
clearly/efficiently (without using Response.Write("") 169 times), not
about printing different things depending on x or y.

-AK
  #4  
Old July 19th, 2005, 11:00 AM
Peter Foti
Guest
 
Posts: n/a
Default Re: printing large blocks of HTML in ASP

"Andrew" <akoper@web4000.com> wrote in message
news:42cdd29b.0401090754.15aa02ca@posting.google.c om...[color=blue]
> I just counted, and the top of my web page is 169 lines of HTML and
> DHTML.
>
> My question was really about printing out large blocks of HTML in ASP
> clearly/efficiently (without using Response.Write("") 169 times), not
> about printing different things depending on x or y.[/color]

Andrew, you wrote:
"I could write a function so that these vars can be interpolated, except I
don't want 70 lines of Response.Write("foo")."

Your assumption that you WOULD need 70 lines of Response.Write("foo") is
wrong. You simply close your ASP and print out regular HTML, using ASP only
for the dynamic pieces. For example, this might go in your include file:

<%
Function printHeader(title)
%>
<head>
<title><%=title%></title>
<script type="text/javascript" src="foo.js"></script>
</head>
<%
End Function
%>

Then you simply call printHeader with the title of your choice from the
page. There is no need for bunch of Response.Write statements.
Hope this helps.
Peter Foti


  #5  
Old July 19th, 2005, 11:00 AM
Dave Anderson
Guest
 
Posts: n/a
Default Re: printing large blocks of HTML in ASP

"Andrew" wrote:[color=blue]
>
> ...Does ASP have a "print HERE" function like Perl
> that prints out large blocks of HTML and interpolates
> variables?
>
> print <<<;
> <html>
> <head><title> strPageTitle </title> ...[/color]

You can certainly use the following in the same manner:

<html><head><title><%=strPageTitle%></title> ...

Since IIS 5+ defaults to buffering the response stream, there is little
penalty for this type of context switching.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.


  #6  
Old July 19th, 2005, 11:00 AM
Jeff Cochran
Guest
 
Posts: n/a
Default Re: printing large blocks of HTML in ASP

On 9 Jan 2004 07:54:53 -0800, akoper@web4000.com (Andrew) wrote:
[color=blue]
>I just counted, and the top of my web page is 169 lines of HTML and
>DHTML.[/color]

Then use HTML/DHTML coding on the page for that section. Use
ASP/VBScript coding where appropriate.

Jeff
  #7  
Old July 19th, 2005, 11:01 AM
Andrew
Guest
 
Posts: n/a
Default Re: printing large blocks of HTML in ASP

I really appreciate everyone who is responding to my question. I have
an important point to clarify/reiterate. When I make web apps in PHP
or Perl, my pages look like this:

<?
include 'utils.inc';
$page = "Create Account";
printHeader($page);
?>

Enter your basic information here to create an account.<p>
Name: <input type="text" name="name" length="15"><p>
More content unique to that page.....

<?
printFooter();
?>

Isn't this brilliant?! Or is it crazy?
_I_create_functions_that_print_the_common_header_a nd_footer_sections_that_include_structural_HTML_
I don't just insert vars. This way, there isn't common HTML
duplicated across the 500 pages of the site I just inherited and am
upgrading. I am going by the programming paradigm of "if you use the
same thing over and over, just write it once and refer to it, don't
write it over and over." This way, if we decide to add another
hyperlink in the menu in the header, it is a 10 minute job, not a 15
hour job. The function printHeader is virtually all HTML, almost like
an include file. It ought to look virtually like an include file,
just all HTML like Perl's "print HERE" function. You ought to be able
to do this in ASP. How?

:)
-AK
  #8  
Old July 19th, 2005, 11:01 AM
Mark Schupp
Guest
 
Posts: n/a
Default Re: printing large blocks of HTML in ASP

<%@ LANGUAGE="VBSCRIPT"%>
<!--#include file="utils.inc"-->
<%printHeader "Create Account"%>

Enter your basic information here to create an account.<p>
Name: <input type="text" name="name" length="15"><p>
More content unique to that page.....

<%printFooter%>

You can use JScript if you prefer, but you'll have to get the correct syntax
from someone else.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com


"Andrew" <akoper@web4000.com> wrote in message
news:42cdd29b.0401091554.2110c104@posting.google.c om...[color=blue]
> I really appreciate everyone who is responding to my question. I have
> an important point to clarify/reiterate. When I make web apps in PHP
> or Perl, my pages look like this:
>
> <?
> include 'utils.inc';
> $page = "Create Account";
> printHeader($page);
> ?>
>
> Enter your basic information here to create an account.<p>
> Name: <input type="text" name="name" length="15"><p>
> More content unique to that page.....
>
> <?
> printFooter();
> ?>
>
> Isn't this brilliant?! Or is it crazy?
>[/color]
_I_create_functions_that_print_the_common_header_a nd_footer_sections_that_in
clude_structural_HTML_[color=blue]
> I don't just insert vars. This way, there isn't common HTML
> duplicated across the 500 pages of the site I just inherited and am
> upgrading. I am going by the programming paradigm of "if you use the
> same thing over and over, just write it once and refer to it, don't
> write it over and over." This way, if we decide to add another
> hyperlink in the menu in the header, it is a 10 minute job, not a 15
> hour job. The function printHeader is virtually all HTML, almost like
> an include file. It ought to look virtually like an include file,
> just all HTML like Perl's "print HERE" function. You ought to be able
> to do this in ASP. How?
>
> :)
> -AK[/color]


  #9  
Old July 19th, 2005, 11:01 AM
David Holley
Guest
 
Posts: n/a
Default Re: printing large blocks of HTML in ASP

Are you familar with the server.execute method? It executes another HTML
page inline inserting any contained HTML or resultant HTML from ASP
code.

For Example....

<html>
<head>
</head>
<body>
Some sort of HTML code here
<% server.execute ("../content/getActiveReservations.asp") %>
Maybe some more HTML code here
<% server.execute ("../content/getCanceledReservations.asp") %>


</body>
</html>

Which might result in the following HTML...

<html>
<head>
</head>
<body>
Some sort of HTML code here
Active Reservations
1/1/2004 Smith, John
1/4/2004 Bush, George
Maybe some more HTML code here
Cancelled Reservations
1/3/2004 Johnson, Lyndon
1/3/2004 Nixon, Edward

</body>
</html>


Is this getting closer?

David H.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #10  
Old July 19th, 2005, 11:01 AM
Stephen Willingham
Guest
 
Posts: n/a
Default Re: printing large blocks of HTML in ASP

Hello Andrew

Perhaps you are searching for something like this (although the solutions offered
above seem to be workable). I have an include file for each site called nav_inc.asp.
There are a couple of subs in there that look like this

--------------------------------------------
<%Sub WriteHeader()%>
<!--begin header-->

<h1>Some html for the header</h1>
...as much html as you care to include...

<!--end header-->
<%End Sub%>

<%Sub WriteFooter()%>
<!--begin footer-->
<h1>Some html for the footer</h1>
...etc
<!--end footer-->
<%End Sub%>
--------------------------------------------

Then in somepage.asp, I include nav_inc.asp at the top of the page and call functions
when I need them

-------------------------------------------
<%WriteHeader()%>

Enter your basic information here to create an account.<p>
Name: <input type="text" name="name" length="15"><p>
More content unique to that page.....

<%
'or if already within some scripting code, just call it without the asp delimiters

WriteFooter()

'some other server processing could be here...
%>
--------------------------------------------

If I understand your question, you just want to write *naked html* without wrapping
it
in 25 Response.Writes. This solution gets all of your common html blocks in one file.
I've also done it by putting the footer or header in it's own individual .asp file,
and then when you would like to write the footer or header, just include the file at
the desired spot in your code. You don't need to wrap the html in subroutine calls
and there does not have to be any asp delimiters in the include files, even though
they have .asp extensions.

--
HTH,
Stephen


"Andrew" <akoper@web4000.com> wrote in message
news:42cdd29b.0401091554.2110c104@posting.google.c om...[color=blue]
> I really appreciate everyone who is responding to my question. I have
> an important point to clarify/reiterate. When I make web apps in PHP> Enter your[/color]
basic information here to create an account.<p>[color=blue]
> Name: <input type="text" name="name" length="15"><p>
> More content unique to that page.....[/color]
[color=blue]
> or Perl, my pages look like this:
>
> <?
> include 'utils.inc';
> $page = "Create Account";
> printHeader($page);
> ?>
>
>
> <?
> printFooter();
> ?>
>
> Isn't this brilliant?! Or is it crazy?
>[/color]
_I_create_functions_that_print_the_common_header_a nd_footer_sections_that_include_str
uctural_HTML_[color=blue]
> I don't just insert vars. This way, there isn't common HTML
> duplicated across the 500 pages of the site I just inherited and am
> upgrading. I am going by the programming paradigm of "if you use the
> same thing over and over, just write it once and refer to it, don't
> write it over and over." This way, if we decide to add another
> hyperlink in the menu in the header, it is a 10 minute job, not a 15
> hour job. The function printHeader is virtually all HTML, almost like
> an include file. It ought to look virtually like an include file,
> just all HTML like Perl's "print HERE" function. You ought to be able
> to do this in ASP. How?
>
> :)
> -AK[/color]


  #11  
Old July 19th, 2005, 11:01 AM
Stephen Willingham
Guest
 
Posts: n/a
Default Re: printing large blocks of HTML in ASP

Sorry Andrew

I see the solution I just offered was already suggested out by Peter above. My
mistake.

--
HTH,
Stephen


"Andrew" <akoper@web4000.com> wrote in message
news:42cdd29b.0401091554.2110c104@posting.google.c om...[color=blue]
> I really appreciate everyone who is responding to my question. I have
> an important point to clarify/reiterate. When I make web apps in PHP
> or Perl, my pages look like this:
>
> <?
> include 'utils.inc';
> $page = "Create Account";
> printHeader($page);
> ?>
>
> Enter your basic information here to create an account.<p>
> Name: <input type="text" name="name" length="15"><p>
> More content unique to that page.....
>
> <?
> printFooter();
> ?>
>
> Isn't this brilliant?! Or is it crazy?
>[/color]
_I_create_functions_that_print_the_common_header_a nd_footer_sections_that_include_str
uctural_HTML_[color=blue]
> I don't just insert vars. This way, there isn't common HTML
> duplicated across the 500 pages of the site I just inherited and am
> upgrading. I am going by the programming paradigm of "if you use the
> same thing over and over, just write it once and refer to it, don't
> write it over and over." This way, if we decide to add another
> hyperlink in the menu in the header, it is a 10 minute job, not a 15
> hour job. The function printHeader is virtually all HTML, almost like
> an include file. It ought to look virtually like an include file,
> just all HTML like Perl's "print HERE" function. You ought to be able
> to do this in ASP. How?
>
> :)
> -AK[/color]


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles