OT - includes in ASP code...

A forum for, well, anything really.
Gripes, moans, ideas or just general chit chat. EXCEPT SPAM!!! - Don't just register to post here - IT WILL GET DELETED!!!
Post Reply
tepidarium
Mega User
Mega User
Posts: 169
Joined: Sun Oct 05, 2003 4:21 am

OT - includes in ASP code...

Post by tepidarium »

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: Select all

<--#include virtual="/includes/top.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]
waitman
Beginner
Beginner
Posts: 5
Joined: Thu May 13, 2004 8:22 am
Location: Buena Park
Contact:

this works better

Post by waitman »

why don't you make one template file and do something like this.


1. content.asp

Code: Select all

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
2. layout.html

Code: Select all

<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,
Waitman Gobble
http://emkdesign.com/
Post Reply