Print Page | Close Window

Custom Objects

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=14271
Printed Date: 30 March 2026 at 10:06am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Custom Objects
Posted By: Scott07
Subject: Custom Objects
Date Posted: 16 March 2005 at 9:02am
How do you create a custom object in asp like you would in java?  I have an asp file which I shall call my class file for an object how to I create an instance of that class file would I be able to do
<%
Dim objectBob
 
objectBob = Server.createobject("classes\bobclass.asp")
%>
 
and if that would work what do you call your constructure methods (the same as the page name?) or do they have to be called to initalise the object?



Replies:
Posted By: Phat
Date Posted: 16 March 2005 at 7:37pm
You do not do that in ASP.

If you want to use functions from another file you would use <!--#include file="../incfile.asp"-->

that will give you access to all the vars and functions in the file incFile.asp



Posted By: Gullanian
Date Posted: 16 March 2005 at 8:16pm
I think he's talking about COM objects.  Saw a great article/tutorial on how to do it, can't actually find it on Google anymore I'm affraid,  it's out there somewhere.


Posted By: Scott07
Date Posted: 18 March 2005 at 8:37am
Yeah I dont want to use an include because that puts the functions or what ever in the file what I am after is being able to create an object of some file that I have already made so for excample you could have
<%
Dim objCust1
Dim objCust2

set objCust1 = Server.CreateObject("somethingordorder")
set objCust2 = Server.CreateObject("somethingorother")

objCust1.AddToOrder(1234,1)
%>

with includes you can only use it once I bleieve so that AddToOrder call would change both customers but as objects have their own attributes the objCust1.AddToOrder call would only change the attributes for that object and not change the other. 


Posted By: Gullanian
Date Posted: 18 March 2005 at 8:56am
Basically create the DLL in VB or whatever your making it in.

Register it on the server.

Create a new instance of it with the syntax you gave above.


Posted By: Scott07
Date Posted: 18 March 2005 at 9:33am
ahh great I though it was something like that but have just worked it out now.  Is there any way to test your objects as in making them do every access and update method before you register them? or you you register it make it crash cause its not right change code then update the dll file?


Posted By: Gullanian
Date Posted: 18 March 2005 at 10:11am
When you save it as a DLL on your computer I think VB automatically registers it.  Otherwise you need to type regsv32 obj.dll or something like that on the server.

I found that if the object crashed I kept needing to reset IIS, or ctrl alt delete the dllhost.exe.


Posted By: Meson
Date Posted: 18 March 2005 at 1:05pm
You can create script components. You ewill find a tool to make them in Microsoft's scripting tools section or their site. Basically you create an xml file with speciallized object tags and embeded scripts.
 
Beter yet, go right to the page: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/letintro.asp - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/letintro.asp


Posted By: Trebz
Date Posted: 18 March 2005 at 5:14pm
Are you talking about simply using a Class in VBScript?
 
In which case, just include your class file, and then do
 
MyObj = New ClassName
 
Thereafter
 
ClassName.Method() etc... will work


-------------
Trebz
Andover TownCentral
http://www.andover.towncentral.co.uk/forum - http://www.andover.towncentral.co.uk/forum



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net