HELP: My ASP class object is crippled if I save it in a session collection

P

Philip Chan

I am using ASP3.0 and IIS5

I want to have OOP so I have define a class call Employee with
property 'fullName' and methods like getFullName().

To save a group of employee in session, I use a dictionary.

-----------------
dim employees
set employees = CreateObject("Scripting.Dictionary")

dim vpOfSales
set vpOfSales = new Employee
vpOfSales.fullName = "Brian Miller"

response.write vpOfSales.getFullName() ' work here
employees.add "vpOfSales", vpOfSales

Set session("employees") = employees
....
-----------------

The problem came when I retrieve the Employee objects in *another*
page
-----------------
dim employees
Set employees = session("employees")
for each person in employees
response.write person.getFullName() ' have error here
next
....
 
B

Bite My Bubbles

hI, iiLL SAVE YOU SOME HAIR PULLING.
I did the same thing, same result.
Turns out this is by design - You can't do that! You can't use classes in
asp, and have them work across pages, such as with session variables

There are articles about it out there, but it comes down to the fact that
since the class can't be guaranteed to be the same across pages, it isn't a
proper class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top