hitmill.com
link to hitmill.com home page

 

 

ASP Server-Side Include File
(SSI File)


 
A server-side include file is a good way to write code once, which will be repeated over several Web pages, such as making a uniform header. The include file can contain HTML, and both client-side or server-side scripts, and images, and will have the extension of either .inc or .asp. (If using ASP code in the SSI file, the SSI file will have to use the .asp extension. If not using the ASP code in the SSI file, either extension is fine.) The include file is stored outside of the Web pages but will be called from any Web page having the .asp extension. If you store the SSI file in a folder just for your SSI files, be sure to use the relative path (url) when calling it from a Web page situated in a different folder:
<!--#include file="../my_ssi/filename.asp" -->

Use code to call the include file, where you want it used in the page; from within a table, a header, a footer area, etc. More than one server-side include (SSI file) may be called from an ASP page.
 
To call the SSI file, use this code:
<!--#include file = "filename.ext" -->
where filename is the name of your server-side include file and ext is either .inc or .asp, for the extension.
 
Here is an example of an include file:
<% @language = "vbscript" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML LANG=en-US>
<HEAD PROFILE="http://purl.org/metadata/dublin_core">
<META HTTP-EQUIV="Content-type" CONTENT="text/html;charset=ISO-8859-1">
<meta name="MSSmartTagsPreventParsing" content="TRUE">
An include file such as this one (above), might have a name such a top.asp, since server-side script is in the include file. This SSI file would be called first from every page in your Web site and the code would not have to be repeated for each individual page; but merely coded once for all of the pages.
The SSI file is not used as a technique to hide code from the user. Any code in the include file is sent to the browser (except the ASP code) and may be seen by the user. In the case of the ASP code, only the results of the ASP go to the browser, not the ASP code itself.
 
You will be able to think of places in your own Web site where your are using repetitive code on each page, such as in a navigation bar, and other places. This is where you will want to write server-side include files (commonly called SSI files) and just call the file each time it is placed on your page.
An example of calling the SSI file from a table:
<table width ="600" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td>
<img src="logo.gif">
</td>
<td>
<!--#include file="topnav.inc"-->
</td></tr></table>
In this example, you can see that you would have to code the table each time the include file is called. Instead of repetively coding the table, just include the entire table right in the SSI file so that the table code is not repeated on each page. The benefit of having tables inside the SSI file is that you only have to redesign a table once, to have it appear site-wide. This will save consider time on site maintenance. If a logo is in the header of your Web page, you can change the logo in the SSI file without having to change any other code on your Web site.
In summary, SSI files cannot be used on pages having an htm or html extension. Only use these SSI files on pages having a .asp extension. SSI files are used to prevent repetitive code, to save time, and to increase ease of site maintenance.
 
C.Gribble
hitmill.com

 
Back

 

 


 
Contact Webmaster
 
Updated
http://www.hitmill.com/dhtml/css/lesson1example.html
© hitmill.com
All Rights Reserved