| Include File ASP Tutorial - ASP Web Pro |
|
ASP TutorialsINCLUDE FILESIf you are getting into web development, especially with ASP programming, include files are going to become one of your best friends. In essence, an include file allows you to write an ASP script one time and then include it in multiple web pages without having to rewrite all the code. So when and how do you do this? One of the most basic examples is placing your database connection within an include statement and then using a simple include statement to include your connection string in your web pages. First, you create a folder named /includes within your root directory. Next, you create a new file named connection.asp and save it within your new /includes folder. All that is left is to input a simple one line include statement into each page where you need to have a database connection. Here is how the include statement looks: <!--#INCLUDE VIRTUAL="/includes/connection.asp"-->
OK, you've got that. Now what is the advantage of using an include file like this? Well, think about it. Let's say your website is 100 pages and that 6 months from now something is your database conenction chages. Rather than having to go through and edit your connection string in all 100 pages, you can simply edit it one time in your include file and that will automatically update it throughout your website. There are two way of including files in a web page. You can use INCLUDE VIRTUAL or INCLUDE FILE. Our preference is to use INCLUDE VIRTUAL. This means that you can just enter the virtual path of your website to the file you want to include. In the example of the path is "/includes/connection.asp".
|
||||
|
Main Menu Other Resources
Last Updated:
|
||||
|
© 1997-2010 ASP Web Pro, Inc. | Terms of Use
|