Server-Side JScript Objects, Part 2By Richard Lowe
In Part 1 we looked at the
createTicket() function for our
Ticket object. In this part we will look at how to tie the
Ticket object by using an object constructor.
The Object Constructor
This syntax can then be applied to the ticket object for the helpdesk project:
The object is now available to ASP using JScript, however most developers will want to continue using VBScript as their primary ASP language. This creates another step in the process, returning an object to VBScript with one more small function:
The partially completed ticket object is now ready to be used in VBScript. It is easiest to place objects
#include files on their own, so that the includes on a particular page are as finely granular
Note, the above script uses with
With block, requiring VBScript 5.0 or greater. To learn more
With block be sure to read: Using the
To determine your VBScript version be sure to read: Determining the Server-Side
Scripting Language and Version.
Implementing JScript objects in a VBScript-driven ASP page takes some planning and patience. However a properly
implemented set of JScript objects in finely granular
#include files can significantly reduce the
cycle time in most sizes of ASP-based project because they:
- Provide functionality that can be re-used by any developer who's ever used COM objects in ASP.
- Allows script-only programmers to use object design prinicples in their ASP application.
- Place functions and properties into logical, easy to use groupings.
Richard Lowe (email@example.com)
Richard Lowe works as a Development Services consultant for Spherion in the Technology Group
objTicket.aspin text format