When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
Related Web Technologies
User Tips!
Coding Tips

Sample Chapters
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
Print this page.
Using Includes

One of the steps to writing more readable and maintainable code is to write code as modular as possible. When writing ASP there are often chunks of code which you find yourself reusing quite often. For example, you may reuse a footer or header or both on each of your webpages (4Guys makes extensive use of footers, headers, what's new pages, etc.)

Also you may have a set of client-side form validation functions written, or some server-side functions that you use often. Rather than cutting and pasting these functions into each ASP page that needs them, it is advised that you employ the use of server-side includes.

To use server side includes, outside of your ASP code (i.e., outside of the <% and %>), include the following line:

<!--#include file="somefile.asp"-->

This will include the file somefile.asp into your ASP page, as though it had all been typed in there by hand. (The above example assumes that somefile.asp is in the same directory as the ASP page which is calling it with the SSI.)

For a more detailed explanation of server side includes (with examples of include file and include virtual, check out Charles Carrol's Include Tutorial.

Happy Programming!

FAQ Table of Contents   Using Option Explicit Inserting Form Responses into Databases 

ASP.NET [1.x] [2.0] | ASPFAQs.com | Advertise | Feedback | Author an Article