Preview

ASP Object - Properties and Methods

Powerful Essays
Open Document
Open Document
4110 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
ASP Object - Properties and Methods
ASP Object
Objects are a way of encapsulating multiple methods (they're like functions) and variables in one easy to manage Uber-Variable (an Object).
Objects were created to combat the increasing complexity of programming. The rationale for understanding and using Objects in your programming is to make programming easier and your code more human readable.

ASP Create an Object - Server.CreateObject
An object in ASP is created by passing a name string to the Server.CreateObject function(actually referred to as a method). The string to create a Message object is "CDO.Message". We will be creating a CDO.Message object in this example.
Note: Because objects are special there is a special way that you create and destroy them using the Set keyword. These areas are marked in red in the example below.
ASP Code:

For example say that you wanted to make an object that allowed you to send an email...
Well there are certain things all emails have: To, From, CC, Subject, etc. This list of variables that are common to every email would be quite tiresome to have to create for every email we sent. Wouldn't it be nice if we could create some sort of Uber-Variable(Object) that would group all these smaller variables into one thing?
ASP Object Properties
These smaller variables are commonly referred to as an object's properties and the format for setting these properties is nearly identical to setting a variable equal to a value.
The correct syntax for setting an object's properties is: objectName.propertyName = someValue
In this tiny example below we are creating a new mail object and setting its To and From properties.
ASP Code:

Application Object
An application on the Web may consists of several ASP files that work together to perform some purpose. The Application object is used to tie these files together.
The Application object is used to store and access variables from any page, just like the Session object. The difference is that ALL users share

You May Also Find These Documents Helpful