Server-Side Includes and ASP

  • Thread starter Nathan Sokalski
  • Start date
N

Nathan Sokalski

I have a segment of HTML code that I want to put in a server-side include.
All but one line of this code will be constant in all file it is included
in. However, there are many places in the HTML that include double quotes.
From what I can conclude, this leaves me with the following options:

1. Make several files to include, 1 for the constant HTML before the
non-constant HTML, 1 for the line of code that is not constant, and 1 for
the constant HTML after the non-constant HTML.

2. Convert the constant html into strings that are created using Chr()
function for all the double quotes and written using Response.Write().

Option 1 requires less effort, but would require more files to keep track of
and would require me to pull 3 files in rather than just 1. Option 2 allows
me to do everything with one file, but would be harder to edit because the
code will no longer look like HTML. Any suggestions? Thanks.
 
J

Jean-Pierre Thomasset

Nathan said:
I have a segment of HTML code that I want to put in a server-side include.
All but one line of this code will be constant in all file it is included
in. However, there are many places in the HTML that include double quotes.
From what I can conclude, this leaves me with the following options:

1. Make several files to include, 1 for the constant HTML before the
non-constant HTML, 1 for the line of code that is not constant, and 1 for
the constant HTML after the non-constant HTML.

2. Convert the constant html into strings that are created using Chr()
function for all the double quotes and written using Response.Write().

Option 1 requires less effort, but would require more files to keep track of
and would require me to pull 3 files in rather than just 1. Option 2 allows
me to do everything with one file, but would be harder to edit because the
code will no longer look like HTML. Any suggestions? Thanks.

Hello,

Option 3 : Why not put a variable in your main template, then affecting
it before including the file.
Here is an example :

template.asp :
<HTML><BODY>
Page Header
<%=MyVar%>
Page Footer
</BODY></HTML>
------------------

And your main page could be :
<%
Dim MyVar
MyVar = "Some text"
%>
<!-- #include file="template.asp" -->
 
N

Nathan Sokalski

I don't think that solves my problem, because I still have to make
everything into a string (in your example MyVar), which presents the same
problem I mentioned in solution #2.
 
J

Jean-Pierre Thomasset

Nathan said:
I don't think that solves my problem, because I still have to make
everything into a string (in your example MyVar), which presents the same
problem I mentioned in solution #2.

Then why not encapsulate everything in a procedure :

template.asp :
<HTML><BODY>
Page Header
<%=MySub%>
Page Footer
</BODY></HTML>
-----------------

And your main page could be :
<%
Sub MySub
' some vbscript
%>
Some text with html tags
<%
End Sub
%>
<!-- #include file="template.asp" -->
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top