To read the article online, visit http://www.4GuysFromRolla.com/webtech/faq/Intermediate/faq7.shtml

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!


Article Information
Article Title: Using Includes
Article Author: Scott Mitchell
Article URL: http://www.4GuysFromRolla.com/webtech/faq/Intermediate/faq7.shtml


Copyright 2017 QuinStreet Inc. All Rights Reserved.
Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers