Session variable question

  • Thread starter Thread starter Amy
  • Start date Start date
A

Amy

Hello,

I'm having an odd issue with accessing a Session variable on a web
form.
If i access it from the PageLoad event, it works fine. If I take it
out of the PageLoad event, I get the error -
"an object reference is required for the nonstatic field, method, or
property "System.Web.UI.Page.Session'"

Can anyone explain why this is happening?

thanks in advance,

Amy
 
Amy,

Without seeing your code, it's impossible to tell. Can you show the
code you are getting the compiler error on?
 
you are most likely trying to access the variable outside of the page
context. You should use the Httpcontext.current qualification instead of the
page class qualification.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top