Back To Start Of Archive
Taken From The Forum: Anything Goes
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:36
OT - includes in ASP code...
Poster: tepidarium
Dated: Tuesday March 23 2004 - 20:24:39 GMT
Does anyone know how to use the #include directive to include a seperate heaer and footer include at the top and botom respectively of an asp file that only contains asp program code and no html tags.
this does not work:
Code:
<--#include virtual="/includes/top.shtml" -->
<%
asp code
%>
<!--#include virtual="/includes/bottom.shtml" -->
<%
asp code
%>
<!--#include virtual="/includes/bottom.shtml" -->
Basically, what will happen is that the top.shtml file will be included but it will wind up as html code before the <html> tag.
The bottom include will not show up at all because it is included after the </html> tag.
[/code]
this works better
Poster: waitman
Dated: Thursday May 13 2004 - 8:48:23 BST
why don't you make one template file and do something like this.
1. content.asp
Code:
strContent = "<h3>Title</h3><p>foo bar foomazooma</p>"
Set FO = Server.CreateObject("Scripting.FileSystemObject")
fn = Server.MapPath("layout.html")
Set TemplateFile = FO.OpenTextFile(fn)
strLayout = TemplateFile.ReadAll
strLayout = Replace( strLayout, "<!--Content-->", strContent )
Response.Write strContent
Set FO = Server.CreateObject("Scripting.FileSystemObject")
fn = Server.MapPath("layout.html")
Set TemplateFile = FO.OpenTextFile(fn)
strLayout = TemplateFile.ReadAll
strLayout = Replace( strLayout, "<!--Content-->", strContent )
Response.Write strContent
2. layout.html
Code:
<html>
<head>
<title></title>
</head>
<body>
<!--Content-->
</body>
</html>
<head>
<title></title>
</head>
<body>
<!--Content-->
</body>
</html>
Then you (or your designers) can actually create layouts using something like Dreamweaver if you really want to. Also, only accessing 2 files instead of 3.
I find that this method makes life much better.
Best Regards,