Creating your own class definition with the traditional ASP

Posted by Daniel - 400 Views

Creating your own class definition with the traditional ASPTo follow the steps on this article you need at least Microsoft Windows 9x and IIS installed. This time we will learn and take a closer look at one of the traditional ASP?s feature, it is the ability to accept coder?s class definition. Long before the release of the .NET framework, this feature remains hidden for most of the coders, including myself. If you already familiar with Visual basic, you won?t find any difficulties implementing this feature into your web application since the structure needed to assemble an ASP class is quite similar to the class structure within the Visual Basic.

OK, lets get into it. Below is a simple class definition example created with traditional ASP, named MotorBike.

Class MotorBike
Private x_MBikeMake

Public Property Get Make()
Make = x_MBikeMake
End Property

Public Property Let Make(z_Make)
x_MBikeMake = z_Make
End Property

Private x_MBikeModel

Public Property Get Model()
Model = x_MBikeModel
End Property

Public Property Let Model(z_Model)
x_MBikeModel = z_Model
End Property

Public Sub Combine()
response.write Make & ” : “ & Model
End Sub
End Class

On the example above, MotorBike Class consists of two private members (the Bike manufacturer and the bike model), four public properties (2 get, 2 set), and a Sub Procedure (combining the bike manufacturer and the bike model).

To use it on your ASP page, add the code below under the class definition, then save it as motor.asp,

Dim objMotorBike
Set objMotorBike = New MotorBike
objMotorBike.Make = “KAWASAKI”
objMotorBike.Model = “Ninja ZX-10R”
objMotorBike.Combine()

If you run the page on your browser, the result is the combination of the bike manufacturer property value and the bike name property value outputted by the Combine Sub of the class. I use this feature to create the SimpleGridBuilder, a very simple database driven grid builder.

share this article

Digg del.icio.us Netscape StumbleUpon Yahoo! MyWeb reddit Furl Magnolia Newsvine Technorati SlashDot Blinklist Simpy Google
This post as PDFPosted in: Programming - January 2008


Leave a Reply


Options for your comment:





Hi, my name is Daniel Nugraha, a single male live on an island called Java, Indonesia. This is the place for me to share my interest in computer programming.

Coffee Break

Comments - Thanks Guys :)

  • Rangga Kusuma: Gan, Tengkiu buat postingan yang sangat berguna. Kebetulan ada project utk bikin sms gateway, dan converter Agan sangat berguna utk...
  • Chuck Norton: I actually went ahead & bolted over to Justin’s Get The Image plugin here: http://justintadlock.com/ar...
  • Chuck Norton: Question: is it possible to insert something like [custfieldimg=”joice1.jpg,15 0,1:1″] into the actual templates instead of...
  • Therese Lachance: Hi, Any idea how to have ContuttoPDF fetch the correct page language?
  • tresloukadu: yo how did u fixed when the tags shows <? and it shows < “& l t ; ” ?? please send me an email.