HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
You can insert the content of one ASP file into another ASP file before theserver executes it, with the #include directive
You can insert the content of one ASP file into another ASP file before the server executes it, with the #include directive.
The #include directive is used to create functions, headers, footers, or elements that will be reused on multiple pages.
Here is a file called "mypage":
Here is the "wisdom.inc" file:
Here is the "time.inc" file:
If you look at the source code in a browser, it will look something like this:
To include a file in an ASP page, place the #include directive inside comment tags:
The Virtual Keyword
Use the virtual keyword to indicate a path beginning with a virtual directory.
If a file named "header.inc" resides in a virtual directory named /html, the following line would insert the contents of "header.inc":
The File Keyword
Use the file keyword to indicate a relative path. A relative path begins with the directory that contains the including file.
If you have a file in the html directory, and the file "header.inc" resides in html\headers, the following line would insert "header.inc" in your file:
Note that the path to the included file (headers\header.inc) is relative to the including file. If the file containing this #include statement is not in the html directory, the statement will not work.
In the sections above we have used the file extension ".inc" for included files. Notice that if a user tries to browse an INC file directly, its content will be displayed. If your included file contains confidential information or information you do not want any users to see, it is better to use an ASP extension. The source code in an ASP file will not be visible after the interpretation. An included file can also include other files, and one ASP file can include the same file more than once.
You cannot open or close a script delimiter in an INC file. The following script will NOT work:
But this script will work: