473,411 Members | 2,019 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

ASP class-session variable

Hiya - Big puzzler for me. Code Below
I create a class. I save it to a session variable.
Then, I retrieve the session variable back into a new local variable.
I am able to use a method which prints the name "Joey."

Works great.

But if I retrieve the same session variable into a local variable from a
different page, I cannot use the method. It fails.
Even though the session variable is an object, and the local variable is an
object!
Why? How can I get to this class from the second page?

thanks

<%
dim oTest

set oTest= new clsEmployee
oTest.EmployeeName="Joey"

set session("sessionTest")= oTest
set oTest= nothing

'This section works fine------------------------------
'But not from another page!
dim oNewTest
set oNewTest = session("sessionTest")
Response.Write "<br>Is oNewTest an object? " & isObject(oNewTest)
Response.Write "<Br>"
Onewtest.PrintEmployeeName
---------------------------------------

Class clsEmployee

Private m_strEmployeeName

Public Property Get EmployeeName
EmployeeName = m_strEmployeeName
End Property

Public Property Let EmployeeName (strEmployeeName)
m_strEmployeeName = strEmployeeName
End Property
Sub PrintEmployeeName
Response.Write EmployeeName
End Sub

End Class

%>
Jul 19 '05 #1
8 7031
I'm pretty sure you can't save VBScript classes into session variables and
expect them to be persisted. I think they are still accessible within the
context of the same ASP page but not when re-loaded to a different page.

M. Harris has posted about this on numerous occasions?

Chris.

"Tammy B." <Tb@stinkylips.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hiya - Big puzzler for me. Code Below
I create a class. I save it to a session variable.
Then, I retrieve the session variable back into a new local variable.
I am able to use a method which prints the name "Joey."

Works great.

But if I retrieve the same session variable into a local variable from a
different page, I cannot use the method. It fails.
Even though the session variable is an object, and the local variable is an object!
Why? How can I get to this class from the second page?

thanks

<%
dim oTest

set oTest= new clsEmployee
oTest.EmployeeName="Joey"

set session("sessionTest")= oTest
set oTest= nothing

'This section works fine------------------------------
'But not from another page!
dim oNewTest
set oNewTest = session("sessionTest")
Response.Write "<br>Is oNewTest an object? " & isObject(oNewTest)
Response.Write "<Br>"
Onewtest.PrintEmployeeName
---------------------------------------

Class clsEmployee

Private m_strEmployeeName

Public Property Get EmployeeName
EmployeeName = m_strEmployeeName
End Property

Public Property Let EmployeeName (strEmployeeName)
m_strEmployeeName = strEmployeeName
End Property
Sub PrintEmployeeName
Response.Write EmployeeName
End Sub

End Class

%>

Jul 19 '05 #2
There really isn't any reason that storing your classes in session variables
shouldn't work, really, if you have just one application with that stored,
but I think that you should probably not store classes in session variables.

Ray at home

--
Will trade ASP help for SQL Server help
"Tammy B." <Tb@stinkylips.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hiya - Big puzzler for me. Code Below
I create a class. I save it to a session variable.
Then, I retrieve the session variable back into a new local variable.
I am able to use a method which prints the name "Joey."

Works great.

Jul 19 '05 #3
Hiya,

Would someone mind telling me what is wrong with the code, or why the code
doesn't work?

Thanks!!
"Ray at <%=sLocation%>" <ra*@ajf8jalskdfna.sefrhja7yasdf.com> wrote in
message news:%2***************@TK2MSFTNGP10.phx.gbl...
There really isn't any reason that storing your classes in session variables shouldn't work, really, if you have just one application with that stored,
but I think that you should probably not store classes in session variables.
Ray at home

--
Will trade ASP help for SQL Server help
"Tammy B." <Tb@stinkylips.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hiya - Big puzzler for me. Code Below
I create a class. I save it to a session variable.
Then, I retrieve the session variable back into a new local variable.
I am able to use a method which prints the name "Joey."

Works great.


Jul 19 '05 #4
Did you try Google?
http://www.google.ca/search?q=asp+st...-8&hl=en&meta=

http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=195

"Tammy B." <Tb@stinkylips.com> wrote in message
news:Os**************@TK2MSFTNGP12.phx.gbl...
Hiya,

Would someone mind telling me what is wrong with the code, or why the code
doesn't work?

Thanks!!
"Ray at <%=sLocation%>" <ra*@ajf8jalskdfna.sefrhja7yasdf.com> wrote in
message news:%2***************@TK2MSFTNGP10.phx.gbl...
There really isn't any reason that storing your classes in session

variables
shouldn't work, really, if you have just one application with that stored, but I think that you should probably not store classes in session

variables.

Ray at home

--
Will trade ASP help for SQL Server help
"Tammy B." <Tb@stinkylips.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hiya - Big puzzler for me. Code Below
I create a class. I save it to a session variable.
Then, I retrieve the session variable back into a new local variable.
I am able to use a method which prints the name "Joey."

Works great.



Jul 19 '05 #5
Ray, what's the SQL Server help you need/want?
"Ray at <%=sLocation%>" <ra*@ajf8jalskdfna.sefrhja7yasdf.com> wrote in
message news:%2***************@TK2MSFTNGP10.phx.gbl...
There really isn't any reason that storing your classes in session variables shouldn't work, really, if you have just one application with that stored,
but I think that you should probably not store classes in session variables.
Ray at home

--
Will trade ASP help for SQL Server help
"Tammy B." <Tb@stinkylips.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hiya - Big puzzler for me. Code Below
I create a class. I save it to a session variable.
Then, I retrieve the session variable back into a new local variable.
I am able to use a method which prints the name "Joey."

Works great.


Jul 19 '05 #6
thanks! I will put my hair back in my head now.


"Tom B" <sh*****@hotmail.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Did you try Google?
http://www.google.ca/search?q=asp+st...-8&hl=en&meta=
http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=195

"Tammy B." <Tb@stinkylips.com> wrote in message
news:Os**************@TK2MSFTNGP12.phx.gbl...
Hiya,

Would someone mind telling me what is wrong with the code, or why the code
doesn't work?

Thanks!!
"Ray at <%=sLocation%>" <ra*@ajf8jalskdfna.sefrhja7yasdf.com> wrote in
message news:%2***************@TK2MSFTNGP10.phx.gbl...
There really isn't any reason that storing your classes in session

variables
shouldn't work, really, if you have just one application with that

stored, but I think that you should probably not store classes in session

variables.

Ray at home

--
Will trade ASP help for SQL Server help
"Tammy B." <Tb@stinkylips.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
> Hiya - Big puzzler for me. Code Below
> I create a class. I save it to a session variable.
> Then, I retrieve the session variable back into a new local variable. > I am able to use a method which prints the name "Joey."
>
> Works great.
>



Jul 19 '05 #7
Oh, nothing specific at the moment. I just put that there so when I ask
questions in the SQL group, hopefully people will be like, "ah, that guy
tries to answer questions in the ASP groups, so I'll give him a couple of
minutes to help him out with the SQL Server questions..." :]

Ray at home

--
Will trade ASP help for SQL Server help
"Tom B" <sh*****@hotmail.com> wrote in message
news:e4**************@TK2MSFTNGP12.phx.gbl...
Ray, what's the SQL Server help you need/want?

Jul 19 '05 #8
I see
"Ray at <%=sLocation%>" <ra*@ajf8jalskdfna.sefrhja7yasdf.com> wrote in
message news:eg**************@TK2MSFTNGP11.phx.gbl...
Oh, nothing specific at the moment. I just put that there so when I ask
questions in the SQL group, hopefully people will be like, "ah, that guy
tries to answer questions in the ASP groups, so I'll give him a couple of
minutes to help him out with the SQL Server questions..." :]

Ray at home

--
Will trade ASP help for SQL Server help
"Tom B" <sh*****@hotmail.com> wrote in message
news:e4**************@TK2MSFTNGP12.phx.gbl...
Ray, what's the SQL Server help you need/want?


Jul 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fernando Rodriguez | last post by:
Hi, I need to traverse the methods defined in a class and its superclasses. This is the code I'm using: # An instance of class B should be able to check all the methods defined in B #and A,...
1
by: Oplec | last post by:
Hi, I'm learning C++ as a hobby using The C++ Programming Language : Special Edition by Bjarne Stroustrup. I'm working on chpater 13 exercises that deal with templates. Exercise 13.9 asks for me...
5
by: kuvpatel | last post by:
Hi I want to refer a class called LogEvent, and use one of its methods called WriteMessage without actually having to create an instance of Logevent. I have tried using the word sealed with...
5
by: Andy | last post by:
Hi all, I have a site with the following architecture: Common.Web.dll - Contains a CommonPageBase class which inherits System.Web.UI.Page myadd.dll - Contains PageBase which inherits...
38
by: looping | last post by:
For Python developers around. >From Python 2.5 doc: The list of base classes in a class definition can now be empty. As an example, this is now legal: class C(): pass nice but why this...
3
by: Hamilton Woods | last post by:
Diehards, I developed a template matrix class back around 1992 using Borland C++ 4.5 (ancestor of C++ Builder) and haven't touched it until a few days ago. I pulled it from the freezer and...
0
by: emin.shopper | last post by:
I had a need recently to check if my subclasses properly implemented the desired interface and wished that I could use something like an abstract base class in python. After reading up on metaclass...
2
by: Cari Elf | last post by:
I wrote a template class that inherits from the PUG xml_tree_walker class so that I can load data from any XML file without having to write a parser for each one. template <class T> class...
19
by: jan.loucka | last post by:
Hi, We're building a mapping application and inside we're using open source dll called MapServer. This dll uses object model that has quite a few classes. In our app we however need to little bit...
5
by: alan | last post by:
Hello world, I'm wondering if it's possible to implement some sort of class/object that can perform mapping from class types to strings? I will know the class type at compile time, like so:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.