Learn ASP file Reference Common sense

Source: Internet
Author: User

ASP File Reference

Previous page Next page #include command to create reusable functions, headers,

Footer, or other elements.

#include command

By using the #include command, we can insert another ASP file before the server executes the ASP file

In this file. The #include command is used to create a function, header, footer, or

He elements and so on.

How to use the #include command

Here is a file named "MyPage.asp":

<body>

<p><!--#include file= "Wisdom.inc"--></p>

<p><!--#include file= "Time.inc"--></p>

</body>

"One should never increase, beyond what's necessary,

The number of entities required to explain anything. " This is the "time.inc" file:

<%

Response.Write (Time)

The source code that%> looks at in the browser should look like this:

<body>

<p> "One should never increase, beyond what's necessary,

The number of entities required to explain anything. " </p>

<p>11:33:42 am</p>

</body>

Syntax for the

To reference the file in ASP, place the #include command in the Comment tab:

<!--#include virtual= "Somefilename"--or:

<!--#include file = "somefilename"-keyword Virtual

The keyword virtual indicates that the path starts with a virtual directory.

If the name "Header.inc" is in a virtual directory named/html, the following line of code inserts the file

Content in "Header.inc":

<!--#include virtual = "/html/header.inc"-keyword File

The keyword File indicates a relative path. The relative path starts at the directory containing the referenced file.

Assuming that the file is in a subfolder of the HTML folder headers, the following code can refer to "Header.inc"

The contents of the file:

<!--#include file = "Headers\header.inc"--note: The path to the referenced file is relative to the reference

of the file. This declaration will not work if the file containing the #include declaration is not in the HTML directory.

You can also use the keyword file and syntax (\) to refer to files in the parent directory.

Hints and Notes

In the section above, we use ". Inc" as the suffix of the referenced file. Note: If the user tries to directly

Browse INC files and the contents of this file will be exposed. If the contents of the referenced file involve confidentiality, the most

Good or use "ASP" as the suffix. The source code in an ASP file is not visible after it is compiled. The referenced file is also

You can reference other files, and an ASP file can refer to the same file multiple times. Changchun Kowloon Male Hospital

Important: The referenced file will be processed and inserted before the script executes.

The following code cannot be executed because ASP executes the #include command before assigning a value to a variable:

<%

Fname= "Header.inc"

%>

<!--#include file= "<%=fname%>" and cannot include file references between script delimiters:

<%

For i = 1 to n

<!--#include file= "Count.inc"-

Next

%> but this script can work:

<% for i = 1 to n%>

<!--#include file= "Count.inc"-

<% Next%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.