M
MS News \(MS ILM\)
Session["strTemp"] = "hello";
string x = Session["strTemp"].ToString();
x = Page.Session["strTemp"].ToString();
x = System.Web.HttpContext.Current.Session["strTemp"].ToString();
string x = Session["strTemp"].ToString();
x = Page.Session["strTemp"].ToString();
x = System.Web.HttpContext.Current.Session["strTemp"].ToString();
Will said:storing that session worked fine, but when I try to
retrieve it from inside a component I'm writing I'm having
problems.. Here is the snippet:
private string strTemp = (String)Page.Session["strSort"];
I get the follwing error when I compile:
testControl.cs(10,36): error CS0120: An object reference
is required for nonstatic field, method, or
property 'System.Web.UI.Page.Session
what am I doing wrong? Thanks
-----Original Message-----
Session["strSort"]
Remember in C# use [ ] ; not ( ) _
Session["strSort"] = "hello";
strTemp = (String)Session["strSort"]; or .ToString();
Something like that
Will said:In vb I used to store and retrieve sessions as follows:
Session("strSort") = "hello"
strTemp = CType(Session("strSort"), String)
how would I do this same thing in C#?
.