469,922 Members | 1,911 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,922 developers. It's quick & easy.

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

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
....
-----------------
ASP complain the object doesn't have a property or method
getFullName().
What is the problem?
Is there a solution?
Jul 19 '05 #1
1 1984
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.
"Philip Chan" <ph*********@uctv.ca> wrote in message
news:2d*************************@posting.google.co m...
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
...
-----------------
ASP complain the object doesn't have a property or method
getFullName().
What is the problem?
Is there a solution?

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Mike | last post: by
5 posts views Thread by Arnold | last post: by
7 posts views Thread by Ben Amada | last post: by
7 posts views Thread by Shane Saunders | last post: by
8 posts views Thread by Bruno Alexandre | last post: by
3 posts views Thread by Trust Me; I'm from the government | last post: by
1 post views Thread by =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post: by
reply views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.