473,320 Members | 1,974 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,320 software developers and data experts.

Object in Session cannot be accessed

Dear all,

Sorry for cross posting.

I have one page, create an object and save it in session scope, and then redirect to another page.In the new page, the object existed in session object, but can not access its property. The code of page one is :
<%
Class SiteInfo
dim SiteID, SiteName
end class

dim site
set site = new SiteInfo
site.SiteID = "01"
site.SiteName = "Microsoft"
set session("formdata") = site

response.redirect "edit.asp"
%>

the code in edit.asp:
<%
if isObject(session("formdata") then
response.write session("formdata").SiteID
end if
%>

the error occured at line "response.write" :
object can not support the property or method: SiteID

Could you please help me to check why this happen?
Appreciate for any advice.
Best Regards
lichunlin
China

Jul 19 '05 #1
8 1465
> I have one page, create an object and save it in session scope,

WHY DOES THIS HAVE TO BE AN OBJECT?????

Just use an array, it will make your life much simpler.
Jul 19 '05 #2
Dear Aaron,

Thanks for your response.
I would like to create it as an object, because I think the object would be more encapsulated when I use the object more and more times.

Thanks & regards
lichunlin

"Aaron [SQL Server MVP]" wrote:
I have one page, create an object and save it in session scope,


WHY DOES THIS HAVE TO BE AN OBJECT?????

Just use an array, it will make your life much simpler.

Jul 19 '05 #3
Does it work when in the same page ?

I would try also to get the object from the session before using it (I
suspect a confusion between the objet that is returned by the session
collection and the object that is stored at this position).

Patrice

--

"Lichunlin" <Li*******@discussions.microsoft.com> a écrit dans le message de
news:FE**********************************@microsof t.com...
Dear all,

Sorry for cross posting.

I have one page, create an object and save it in session scope, and then redirect to another page.In the new page, the object existed in session
object, but can not access its property. The code of page one is : <%
Class SiteInfo
dim SiteID, SiteName
end class

dim site
set site = new SiteInfo
site.SiteID = "01"
site.SiteName = "Microsoft"
set session("formdata") = site

response.redirect "edit.asp"
%>

the code in edit.asp:
<%
if isObject(session("formdata") then
response.write session("formdata").SiteID
end if
%>

the error occured at line "response.write" :
object can not support the property or method: SiteID

Could you please help me to check why this happen?
Appreciate for any advice.
Best Regards
lichunlin
China

Jul 19 '05 #4
> I would like to create it as an object, because I think the object would
be more encapsulated when I use the object more and more times.

So, it is more important that it is "more encapsulated", or that it
functions???

Also, are you aware of the dangers of placing (even simple) objects in the
session/application scope? http://www.aspfaq.com/2053

--
http://www.aspfaq.com/
(Reverse address to reply.)
Jul 19 '05 #5
Lichunlin <Li*******@discussions.microsoft.com> wrote in message news:<FE**********************************@microso ft.com>...
Dear all,

Sorry for cross posting.

I have one page, create an object and save it in session scope, and then redirect to another page.In the new page, the object existed in session object, but can not access its property. The code of page one is :
<%
Class SiteInfo
dim SiteID, SiteName
end class

dim site
set site = new SiteInfo
site.SiteID = "01"
site.SiteName = "Microsoft"
set session("formdata") = site

response.redirect "edit.asp"
%>

the code in edit.asp:
<%
if isObject(session("formdata") then
response.write session("formdata").SiteID
end if
%>

the error occured at line "response.write" :
object can not support the property or method: SiteID


Did you copy and paste this code? If so, you're missing a ) at the following line

if isObject(session("formdata") then
Jul 19 '05 #6
Patrice,

Thanks a lot, It can work in the same page, just can not when redirect to another page.

I store the object in session scope just because I want to transfer the object into another page. If you have other more useful way to do so, please let me know, thanks.

Best regards
lichunlin

"Patrice" wrote:
Does it work when in the same page ?

I would try also to get the object from the session before using it (I
suspect a confusion between the objet that is returned by the session
collection and the object that is stored at this position).

Patrice

--

"Lichunlin" <Li*******@discussions.microsoft.com> a écrit dans le message de
news:FE**********************************@microsof t.com...
Dear all,

Sorry for cross posting.

I have one page, create an object and save it in session scope, and then

redirect to another page.In the new page, the object existed in session
object, but can not access its property. The code of page one is :
<%
Class SiteInfo
dim SiteID, SiteName
end class

dim site
set site = new SiteInfo
site.SiteID = "01"
site.SiteName = "Microsoft"
set session("formdata") = site

response.redirect "edit.asp"
%>

the code in edit.asp:
<%
if isObject(session("formdata") then
response.write session("formdata").SiteID
end if
%>

the error occured at line "response.write" :
object can not support the property or method: SiteID

Could you please help me to check why this happen?
Appreciate for any advice.
Best Regards
lichunlin
China


Jul 19 '05 #7
Dear Aaron,

I just want to class to encapsulate all properties, I feel it useful.And I store the object into session scope just because I want to transfer into other asp page, the new page can access the object. If you have other useful way to do so, please feel free to let me know. Thanks a lot.

Best Regards
lichunlin

"Aaron [SQL Server MVP]" wrote:
I would like to create it as an object, because I think the object would

be more encapsulated when I use the object more and more times.

So, it is more important that it is "more encapsulated", or that it
functions???

Also, are you aware of the dangers of placing (even simple) objects in the
session/application scope? http://www.aspfaq.com/2053

--
http://www.aspfaq.com/
(Reverse address to reply.)

Jul 19 '05 #8
A bit hard without the whole picture. Generally data are listed and a A href
link allows to go on the edit page with the id on the querystring. The whole
data are then retrieved from the db for editing (genrally the list has
anyway a subset of all the fields).

As a side note, you can also have an object stores its properties using the
session object instead of storing the object itself...

Patrice

--

"Lichunlin" <Li*******@discussions.microsoft.com> a écrit dans le message de
news:3C**********************************@microsof t.com...
Patrice,

Thanks a lot, It can work in the same page, just can not when redirect to another page.
I store the object in session scope just because I want to transfer the object into another page. If you have other more useful way to do so, please
let me know, thanks.
Best regards
lichunlin

"Patrice" wrote:
Does it work when in the same page ?

I would try also to get the object from the session before using it (I
suspect a confusion between the objet that is returned by the session
collection and the object that is stored at this position).

Patrice

--

"Lichunlin" <Li*******@discussions.microsoft.com> a écrit dans le message de news:FE**********************************@microsof t.com...
Dear all,

Sorry for cross posting.

I have one page, create an object and save it in session scope, and
then redirect to another page.In the new page, the object existed in session
object, but can not access its property. The code of page one is :
<%
Class SiteInfo
dim SiteID, SiteName
end class

dim site
set site = new SiteInfo
site.SiteID = "01"
site.SiteName = "Microsoft"
set session("formdata") = site

response.redirect "edit.asp"
%>

the code in edit.asp:
<%
if isObject(session("formdata") then
response.write session("formdata").SiteID
end if
%>

the error occured at line "response.write" :
object can not support the property or method: SiteID

Could you please help me to check why this happen?
Appreciate for any advice.
Best Regards
lichunlin
China


Jul 19 '05 #9

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

Similar topics

3
by: Michael J. Astrauskas | last post by:
I have a site where a user logs in and a session variable I created is used to keep track of the fact that the user is logged in. This various pages query a MySQL database to get information...
0
by: EP | last post by:
Hello, Could someone tell me what this error is trying to indicate. I do not get a line number or reference indicating where the error is occuring. Thanks in advance.
2
by: Paul Tomlinson | last post by:
I am trying to call a delegate on my parent from a child thread, this is my code, however i'm getting an exception "Object type cannot be converted to target type." which I can't understand. The...
0
by: Dica | last post by:
i'm getting an error when trying set my dataAdapter's selectCommand. the sqlStatement is a storedProc which takes parameters, so it's constructed as: sqlSelectCommand1.CommandText = ""; ...
5
by: Abhilash.k.m | last post by:
This is regarding the session management using Out of proc session management(SQL SERVER). Among the samples below which one is better to set the session? 1. There are 20 session...
4
by: Kim Bach Petersen | last post by:
I would like to record user behavior data stored in session variables. Since the data is modified throughout each session it seemed obvious to store the data when the session terminates - using...
2
by: John Mullin | last post by:
We are having a problem which appears similar to a previous posting: http://groups.google.com/groups?hl=en&lr=&frame=right&th=d97f552e10f8c94c&seekm=OZw33z9EDHA.2312%40TK2MSFTNGP10.phx.gbl#link1 ...
4
by: Barry | last post by:
object type cannot be converted to target type - i am getting this error message occuring numerous times in my task list, my project compiles and runs ok but it is a nuisance, I think Ihva eheard of...
3
by: news.microsoft.com | last post by:
I got this error "Object type cannot be converted to target type" in my VB Winforms application. When I click on it, it goes no where, how do I troubleshoot this? Thank you.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...

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.