Easy Tutorial
❮ Prop Attributes Folder Met Write ❯

ASP Quick Reference


ASP Quick Reference from tutorialpro.org. Print it out, put it in your pocket, for quick access anytime.


Basic Syntax

ASP scripts are enclosed by <% and %>. Writing output to the browser:

<html>

The default language in ASP is VBScript. To use another scripting language, insert a language directive at the top of the ASP page:

<%@ language="javascript" %>
<%

Forms and User Input

Request.QueryString is used to collect values from forms with method="get". Information sent from a form with the GET method is visible to everyone (it will be displayed in the browser's address bar) and has limits on the amount of information to send.

Request.Form is used to collect values from forms with method="post". Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send.

ASP Cookies

Cookies are often used to identify users. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too.

The Response.Cookies command is used to create a cookie:

<%

Note: The Response.Cookies command must appear before the <html> tag!

The Request.Cookies command is used to retrieve a cookie value:

<%

Including Files

By using the #include directive, you can insert the content of another ASP file into the ASP file before the server executes it. The #include directive is used to create functions, headers, footers, or elements that will be reused on multiple pages.

Syntax:

<!--#include virtual="somefile.inc"-->

Use the keyword virtual to indicate a path starting with a virtual directory. If a file named "header.inc" is located in the virtual directory /html, the following line will insert the content of "header.inc":

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

Use the keyword file to indicate a relative path. The relative path starts with the directory containing the referencing file. If you have a file in the html directory and "header.inc" is located in the html headers, the following line will insert the content of "header.inc" into your file:

<!-- #include file ="headersheader.inc" -->

Use the keyword file with the syntax (..) to reference files in higher-level directories.

Global.asa

The Global.asa file is an optional file that can contain declarations of objects, variables, and methods that are accessible to all pages in an ASP application.

Note: The Global.asa file must be located in the root directory of the ASP application, and each application can have only one Global.asa file.

The Global.asa file can only contain the following:

Application and Session Events

In Global.asa, you can instruct the application and session objects what to do when an application/session starts and ends. The code to accomplish this is placed in event handlers. Note: Since we cannot use ASP script delimiters (<% and %>) in the Global.asa file to insert scripts, we need to place subroutines inside the HTML <script> tags:

<script language="vbscript" runat="server">

<object> Declaration

You can create objects with session or application scope in the Global.asa file using the <object> tag. Note: The <object> tag should be placed outside the <script> tags!

Syntax:

&lt;object runat="server" scope="scope" id="id"

TypeLibrary Declaration

A TypeLibrary is a container for the DLL files that correspond to COM objects. By including a call to the TypeLibrary in the Global.asa file, you can access the constants of the COM object, and the ASP code can report errors better. If your web application relies on COM objects that have data types declared in the type library, you can declare the type library in Global.asa.

Syntax:

&lt;!--METADATA TYPE="TypeLib"

Session Object

The Session object is used to store information about, or change settings for, a user session. Variables stored in the Session object hold information about one single user and are available to all pages in one application.

Collections

Properties

Methods

Application Object

A group of ASP files that work together to perform a task is called an application. The Application object is used to tie these files together. All users share one Application object. The Application object holds information that will be used by many pages in the application (like database connection information).

Collections

Methods

Response Object

The Response object is used to send output from the server to the user.

Collections

Properties

Methods

Request Object

When a browser requests a page from a server, this action is called a request. The Request object is used to get information from the user.

Collections

Properties

Methods

Server Object

The Server object is used to access properties and methods on the server.

Properties

Methods

❮ Prop Attributes Folder Met Write ❯