| To read the article online, visit http://www.4GuysFromRolla.com/webtech/faq/Beginner/faq6.shtml |
|
The previous FAQ discussed the importance of using functions in your ASP to modularize your code. Unfortunately, a function written in one ASP file cannot be accessed by a separate ASP file. That is what includes are useful for (among other things).
Includes are similar to Now, we can include that code in another ASP file. This HTML file will output "Hello, World" to the client's browser screen. By using the include file, it was as if we had just typed the text from the file PrintHelloWorld.asp directly into the above source code.
To include a file, the syntax is like an HTML comment. You need the
If, however, the file is in a different directory altogether, you need to
use
or
Let's look at one more quick example of
Now, if we have an ASP page that we want to use the square function, we
would simply type the following code:
Note that it was if we had typed in the file SquareFunction.asp into the
ASP file above. The use of include files in ASP is good programming
technique, for it allows one copy of source code to be used multiple
times. You should strive to write your ASP applications as modular as
possible, and include files help you do just that!
|
| Article Information | |
| Article Title: | Using Includes |
| Article Author: | Scott Mitchell |
| Article URL: | http://www.4GuysFromRolla.com/webtech/faq/Beginner/faq6.shtml |
Copyright 2010 QuinStreet Inc. All Rights Reserved.
Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers