Page 243 - DCAP408_WEB_PROGRAMMING
P. 243
Unit 9: ASP Objects
9.7 Summary Notes
An object is a software representation of a real-world item, or object. Software objects
feature properties, methods, and events.
Each property of the object describes a particular aspect of the object. The property is
actually described as a name/value pair. This means that for every named property, there
is a single unique value that describes that property for this instance of the object.
By an instance of a object we are about a particular telephone object that has a specific set
of properties and values The instances of an object represent completely different physical
objects. However they share the same types of characteristics such as methods, properties
and events. When a specific instance of an object is created from the template for the object,
the object is said to have been instantiated.
Once we have created an instance of an object, we can tell it to perform a certain task
calling one of its methods.
A class in ASP is like a set of design rules that an object must conform to. In a class there
should be a minimum set of functions that your object must be able to perform.
A method is defined as an action that an object can take. The code in a method is executed
when the method is called. This calling is done by a command you write in the script of
your ASP page.
Methods are actually blocks of code that are written by the designer of the object. It
relieves the programmers of writing the same code again and again as they come bundled
with the object.
Some of the methods can be executed directly, while others need additional information.
A method can have none, one, or more than one parameter. Information passed as
parameters of the method for execution by the method, will only be executed if all
parameters have been supplied.
Method can also return information to us. The value returned by a method is called a
return value. If a method has a return value, then it will pass information back to us. This
information could have a number of purposes. As the user of an object, we can decide
whether we want to do anything with the return value. If the information is pertinent to
what we are doing, then we can capture the return value and do something with it later.
If we do not care what the return value is, we can just ignore it and continue with our work.
An object generates an event whenever something of interest happens. Just like methods,
events can have parameters. These parameters can hold specific information about the
event. When an object generates an event, the object can be said to fire the event. When the
object has fired the event, we say that the user must handle the event.
The inbuilt ASP objects include Application, ASPError, ObjectContext, Response, Request,
Server and Session.
An application on the Web may be a group of ASP files. The ASP files work together to
perform some purpose. The Application object in ASP 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 one Application object, while with
Sessions there is one Session object for EACH user.
The Application object should hold information that will be used by many pages in the
application (like database connection information). This means that you can access the
information from any page. It also means that you can change the information in one
place and the changes will automatically be reflected on all pages.
LOVELY PROFESSIONAL UNIVERSITY 237