Working with Objects

Script writers often find that they need to accomplish certain tasks in their scripts on a regular basis. For example, you might have a number of scripts, all of which ultimately perform different tasks, but all of which need to get information from a user. Objects save you the labor of reinventing the wheel every time you need to perform such a common task. An object is a combination of programming and data that can be treated as a unit.

To use most objects, you must first create an instance of that object. (For more information about creating instances of objects, refer to Working with Components.) However, Active Server Pages (ASP) includes five objects that do not require instantiation. The following table summarizes these inline objects, the tasks you can use them to accomplish, and where to look for examples.

Use the To Find examples in
Request object Get information from a user. Getting Information from a User
Response object Send information to a user. Sending Information to a User
Server object Perform utility tasks on your Web server. Working with Components
Session object Store information about a user’s session. Developing Active Server Pages Applications
Application object Share information among users of an application. Developing Active Server Pages Applications

Object Syntax

The syntax by which you gain access to an object depends on the scripting language you are using. Refer to Using Scripting Languages for more information. Because the default primary scripting language of ASP is VBScript, the examples that appear in this guide use VBScript syntax, except where noted otherwise. If you want to use another scripting language, refer to that language's documentation for the appropriate syntax to work with objects.

Some objects contain collections. A collection is a set of related pieces of information that are accessed the same way.

You gain access to objects and collections from a script by way of methods and properties.

Note   You can also access information in a collection using the For...Each procedure. Refer to Debugging Scripts for more information about this procedure.

Using Methods

A method is a procedure that acts on an object. The syntax is

Object.Method Variant Data String URL

Whether a method requires a variant, data, a string, or a URL depends on the method; refer to Object Reference for more information about a specific method.

Using Properties

A property is a named attribute of an object. Properties define object characteristics, such as size, color, and screen location; or the state of an object, such as enabled or disabled. The syntax is

Object.Property nMinutes  NumSeconds  StatusDescription  date time  ContentType   flag 

Whether a property requires a value, string, or flag depends on the property; refer to Object Reference for more information about a specific property.


© 1996 Microsoft Corporation. All rights reserved.