4:20 am Saturday, February 04, 2012
     
SERVER TRANSFER COMPLETE. UNDER CONSTRUCTION.
            Search About Contact Home
AaronOutpost : ASP / Web Design / Include Files Tutorial For ASP

Include Files For ASP

Back to Web Design Tutorials          Back to ASP Tutorials

Though this tutorial may be for including files with ASP, most languages support the option to include files. Just the code is slightly different.

Include files is a great feature and will hopefully become a great resource to yourself. I use include files in all of my application as well as my website. Instead of re-entering the same code over and over again you can create one file and include it on other pages. Such as a page header and footer. You will notice on AaronOutpost.com there is the same header and footer on every page. I used an include file to load header.asp and footer.asp which are in my virtual directory. So how can you do it?

Include file command only works on .ASP files but it is actually entered outside the script tags <% %>.

<!-- This script will fail -->
<%

If view <> "print" Then

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

End If

%>


<!-- This script will work -->

<%

If view <> "print" Then %>

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

<% End If %>

 

The virtual and file keywords indicate the type of path you are using to include the file, and filename is the path and file name of the file you want to include.

Included files do not require a special file name extension; however, it is considered good programming practice to give included files an .inc extension to distinguish them from other types of files. I however do not do this because it makes for easier editing if all files have the same extension .asp. I name my include files inc_filename.asp

 

Using the Virtual Keyword

This uses the virtual directory as a base. I use this for the include files that you see on the left and right side of AaronOutpost.com. Since you will be browsing multiple directories on the website, I needed to have the files link to it's physical place on the server. Let's say you have a my calendar on your website. It would reside in Calendar. You want to include the mini calendar on all of the pages so you would use the following.

 

<!-- #include virtual ="Calendar/inc_mini_calendar.asp" -->

 

Using the File Keyword

Now lets say you want to use the relative directory. Maybe you want the header to change depending on what directory you are in.

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

Now you can still call files from sub directories using the file command.

<!-- #include file ="includes/header.asp" -->

 

So create a header.asp and a footer.asp that contains an html layout for your website. Your include files can also contain ASP script. In the final example I include AaronOutpost.com Header and Footer files.
 

 


AaronOutpost : ASP / Web Design / Include Files Tutorial For ASP
Random_Image
News & Updates

ASP Inline Calendar 3.9 (January 5, 2008)
Future Home of News & Updates (January 5, 2008)

 

Photo Special

Schedule an appointment

Available in & around:
Centreville VA, Spotsylvania VA,
Summersville WV, & Charleston WV
.

  • NAME YOUR PRICE
    • Email your:
    • Event
    • Hours Needed
    • Photos Needed
    • Disks or Prints
    • and Price You're Willing To Pay
ASP Inline Calendar

$100 Installation Special

PROFESSIONAL INSTALLATION OF YOUR ASP INLINE CALENDAR. REDUCE THE HASSLE, LET US INSTALL YOUR ASP INLINE CALENDAR. SEND A FORMAL REQUEST FOR INSTALLATION WITH SERVER ACCESS INFORMATION. WE WILL NEED FTP ACCESS ALONG WITH CONTROL PANEL ACCESS.

Purchase A Calendar
Information
Demo
Ask A Question

User must provide ftp access to server. Installations are not guaranteed. We work with your service provider to get your calendar installed.

 

Centreville, VA      -      Spotsylvania, VA      -      Charleston, WV      -      Summersville, WV

© Copyright AaronOutpost.com 2012. All rights reserved.