Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I have a object i stored this in a session["asp"]. when i am going to another page i want to call the same object there. i used the code like this

C#
//storing the object in session

   Session["asp"] = objSer;

//in another page i am calling the session to store in new object and i have some thing to check there

 object objserials =Session["asp"];


i am unable to get the count of the session, means i have 5 values in it

and if objserials. (nothing is comming, some default values are coming.)

Regards,
s.Basha
Posted
Updated 27-Dec-11 3:17am
v3
Comments
coded007 27-Dec-11 9:16am    
edited "pre" tags
Sergey Alexandrovich Kryukov 27-Dec-11 11:20am    
What is "call a session into object"? Like "Hey, session, come here, into this object, don't be afraid"? What is "call object"? You can only call a function/method/procedure, even a property (getter/setter), nothing else.
Even a delegate instance can be invoked, which is very different from a call.
--SA

1 solution

You have to cast it to the appropriate type. So, if objSer was an int, you'd have to do this:
C#
int value = (int)Session["asp"];

or, more appropriately:
C#
int value;
Int32.TryParse(Session["asp"], out value);
 
Share this answer
 
Comments
inayat basha 27-Dec-11 9:19am    
objSer is collection of types, mean to say it has so many records in it. like id,name,description
Sergey Alexandrovich Kryukov 27-Dec-11 11:20am    
So..?
--SA
#realJSOP 27-Dec-11 11:24am    
You STILL have to cast it to the correct type before you can use it.
Sergey Alexandrovich Kryukov 27-Dec-11 11:20am    
Yes, a 5.
--SA
Espen Harlinn 30-Dec-11 9:33am    
5'ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900