Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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
 
//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 27-Dec-11 4:13am
Edited 27-Dec-11 4:17am
coded0077.1K
v3
Comments
coded007 at 27-Dec-11 9:16am
   
edited "pre" tags
SAKryukov at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You have to cast it to the appropriate type. So, if objSer was an int, you'd have to do this:
int value = (int)Session["asp"];
or, more appropriately:
int value;
Int32.TryParse(Session["asp"], out value);
  Permalink  
Comments
inayat basha at 27-Dec-11 9:19am
   
objSer is collection of types, mean to say it has so many records in it. like id,name,description
SAKryukov at 27-Dec-11 11:20am
   
So..?
--SA
John Simmons / outlaw programmer at 27-Dec-11 11:24am
   
You STILL have to cast it to the correct type before you can use it.
SAKryukov at 27-Dec-11 11:20am
   
Yes, a 5.
--SA
Espen Harlinn at 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)

  Print Answers RSS
0 OriginalGriff 587
1 Sergey Alexandrovich Kryukov 479
2 Maciej Los 305
3 BillWoodruff 220
4 Mathew Soji 195
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,817
2 DamithSL 5,461
3 Manas Bhardwaj 4,946
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 27 Dec 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100