Modularity and reusability of code can be very useful in your development of ASP scripts. For example, if you want to display copyright information on the bottom of each of your HTML pages and ASP pages, ASP provides a solution to this problem: server-side includes, which are directives to the server to include a certain file, which can be a text file, graphical image, or an ASP function. The copyright notice can exist as one file, and be included into the rest of your Web site's files. And if the copyright notice changes, you only have to change one file instead of 50 or 500.
The syntax for including a file is:
<!-- #include PathType=Name -->
The PathType parameter consists of a keyword, either FILE or VIRTUAL, which indicates whether the Name string specified is a physical or virtual path.
This example uses the #include directive to include the file HeaderInfo.asp. When this script is executed, ASP loads the script line by line, character by character, until it gets to the #include directive, at which point it loads the contents of the designated file, line by line. Then the remainder of the sample script is loaded; once this is finished the script is executed, included file and all.
Note If the file that your ASP script includes contains a large number of functions and variables that are not used by the including script, the extra resources occupied by these unused structures can adversely affect performance, and ultimately decrease the scalability of your Web application. Therefore, it is generally advisable to break your include files into multiple smaller files, and include only those files required by your ASP script, rather than include one or two larger include files that may contain unneeded information.
The VBScript and JScript versions of this script are available in the IIS samples directory, at ...\asp\simple\Includes_VBScript.asp and ...\asp\simple\Includes_JScript.asp.