> ' A check on failedObj shows that it is not null-- it is set to an
> object.
>
> Response.Write failedObj.age
>
> ' Boom! A "Object does not support this method or property" error
> occurs here. "FailedObj" appears not to be "cast" as a type.
>
>
In this section you use failedObj.age when the class defines nAge...
--- In padnug@xxxxxxxxxxxxxxx, "Perry Pederson" <perandtim@xxxx>
wrote:
>
> I've stumbled onto an asp problem at work where I'm cleaning up a
ton
> of code, and needed to store some ASP 'class' data types (a user
> defined type consisting of variant variables) in a
ASP "dictionary",
> which serves as a "collection" container.
>
> All was going well until I found out that I needed to persist the
> contents of the collection container across a ASP page reload. I
> stored the collection into the Session object and can restore it
from
> the Session object without problems. The (restored) container
shows
> that it has the "original" keys and number of "class" data types
> stored in the container, but when I attempt to access a "member"
of
> the class data type, I get a "Object does not support this method
or
> property" error. Since I can't do a cast in ASP, I'm not sure how
to
> restore the class objects, unless I hack a form of serialization
into
> the code.
>
> In case it's difficult to follow my description, here's a simple
> version of what I'm doing:
>
> (ASP, not ASP.NET):
>
> class person
> dim nAge
> end class
>
> dim Jane
>
> Jane = new person
> Jane.nAge = 42
>
> dim objCollection
> set objCollection = Server.CreateObject("Scripting.Dictionary")
>
> objCollection.Add "Person1", Jane
>
> ' Example: Jane can be restored out of the collection:
>
> dim aPerson
>
> set aPerson = objCollection.Item("Person1")
>
> Response.Write aPerson.nAge
>
> ' 42 is printed out-- proof that Jane's data can be obtained out
of
> the collection.
>
> Session("Preserved_Dictionary") = objCollection ' store the
collection
>
> [ ASP page reloads; objCollection is disposed. Attempt to restore
> the info stored in the Session object ]
>
> dim newCollection
>
> set newCollection = Session("Preserved_Dictionary")
>
> Response.Write newCollection.Count
>
> ' 1 is printed; the new collection contains one object
>
> ' Additional proof that the newCollection contains info:
>
> dim svar
> dim keys
>
> svar = gdictSVAInfo.Items
> keys = gdictSVAInfo.Keys
>
> for i = 0 to newCollection.Count-1
>
> Response.Write "#" & i & " k: " & keys(i) & ": "
>
> if isnull(svar(i)) then
> Response.Write "null"
> else
> Response.Write "not null"
> end if
>
> Response.Write "<br>"
>
> next
>
> ' output is "#0 k: Person1: not null"
>
> ' Cool! The object exists, the key (Person1) was restored, let's
use
> it!
>
> dim failedObj
>
> set failedObj = newCollection.Item("Person1")
>
> ' A check on failedObj shows that it is not null-- it is set to an
> object.
>
> Response.Write failedObj.age
>
> ' Boom! A "Object does not support this method or property" error
> occurs here. "FailedObj" appears not to be "cast" as a type.
>
>
> Attempts to cast to a "class" type don't work, as all variables in
> ASP are variants and only base type converstions (CStr, CBool,
etc.)
> are supported.
>
> Any help on this rather odd case would be very much welcome!
>
> Thanks for reading,
>
> Perry
------------------------ Yahoo! Groups Sponsor --------------------~-->
$4.98 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/Q7_YsB/neXJAA/yQLSAA/dpFolB/TM
--------------------------------------------------------------------~->
|