Results 1 to 6 of 6

Thread: How to Use the #include Directive in ASP?

  1. #1
    Join Date
    Jul 2006
    Posts
    339

    How to Use the #include Directive in ASP?

    I have done all basic programs in ASP. I am stuck at a point. I am not able to use the include Directive. I have tried to do lot of things but unluckily was not successful. Can anyone explain me how to use the #include Directive in ASP? Also can I insert the content of one ASP file into another ASP file before the server executes it.?? It would be better if someone provide me the proper coding for including Directive in ASP.!! Please help me soon.!!

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: How to Use the #include Directive in ASP?

    Hope that you have enjoyed doing the basic programs in ASP. ASP allows to include files within ASP pages, by using the #include ASP directive. The #include directive lets you include elements in a web page such as a form, header, footer, navigation and embed them into another page. You can insert the content of one ASP file into another ASP file before the server executes it, with the #include directive. It's a great way to keep a uniform look and feel across your entire website. ASP include files are very useful for creating common pieces of ASP code, which can be reused by many ASP pages and applications. Server-Side Include Directive Syntax is an article about server-side include directive syntax which helps in adding content of a file into any desired place in an ASP.NET page.

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    Re: How to Use the #include Directive in ASP?

    The #include directive is used to create functions, headers, footers, or elements that will be reused on multiple pages. This is an online article that can be used by the users to gather information about Server Side Include Directives. A large website with dynamic content might have a common header and footer, which can be separated in 2 files and simply included on all website pages. You can insert the content of one file into another ASP file, with the ASP #include directive. You have to put your ASPX files where they should be, otherwise the users will not be able to access it. Although you can use server-side includes in ASP.Net, they are procedural in
    nature, and should generally be avoided. It's also a time saver when having to add new text such as the copyright date or a new navigation menu item.

  4. #4
    Join Date
    Mar 2008
    Posts
    672

    Re: How to Use the #include Directive in ASP?

    I am giving you the syntax for including files, so that it will be useful for you to use it in your coding. You will have to place the #include directive inside comment tags, to include a file in an ASP page.
    Code:
    <!--#include virtual="filename"-->
    
    or
    
    <!--#include file ="filename"-->
    You can also use the virtual keyword to indicate a path beginning with a virtual directory. The following is an example for that :
    Code:
    <!-- #include virtual ="/demo/html/header.inc" -->
    The above line would insert the contents of "header.inc", if a file named "header.inc" resides in a virtual directory named /html.

  5. #5
    Join Date
    Jul 2006
    Posts
    289

    Re: How to Use the #include Directive in ASP?

    You can use the #include Directive in ASP as I have used in the following example.
    HTML Code:
    <html>
    <body>
    <h3>Introduction</h3>
    <p>"You should make decisions very fast."</p>
    <h3>The time is:</h3>
    <p>09:44:22 AM</p>
    </body>
    </html>
    The above code consists of various files, including the .asp
    Signatures reduce available bandwidth

  6. #6
    Join Date
    Nov 2008
    Posts
    1,192

    Re: How to Use the #include Directive in ASP?

    I think that you can use the #include directive in ASP. Still I thought to explain you more about that. When using ASP #include directive the file is inserted before the server actually processes it. The following code shows how to include a simple text file into an ASP page by using the #include ASP directive along with the file keyword.
    Include file code (inc.txt):
    This is my website!
    ASP page code (default.asp) :
    HTML Code:
    <html>
    <body>
    <!--#include file="inc.txt"-->
    <%
    ‘ASP server-side code goes here
    %>
    </body>
    </html>
    When including files with the file keyword we are indicating that the file path is relative to the directory.

Similar Threads

  1. what is the use of iostream directive?
    By Diellza in forum Software Development
    Replies: 4
    Last Post: 08-01-2011, 12:46 AM
  2. A fatal error or timeout occurred while processing this directive
    By Xan Mathew in forum Networking & Security
    Replies: 5
    Last Post: 18-06-2010, 05:47 PM
  3. How can I use the pragma directive in C?
    By Tailor in forum Software Development
    Replies: 3
    Last Post: 21-01-2010, 08:39 AM
  4. Explain #define preprocessor directive
    By Javiier in forum Software Development
    Replies: 3
    Last Post: 14-11-2009, 10:12 PM
  5. Replies: 0
    Last Post: 04-06-2009, 10:49 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,013,098.06133 seconds with 17 queries