473,326 Members | 2,102 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,326 software developers and data experts.

Session variable question

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
Nov 17 '05 #1
3 5239
Amy,

Without seeing your code, it's impossible to tell. Can you show the
code you are getting the compiler error on?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Amy" <am*******@mccombs.utexas.edu> wrote in message
news:gd********************************@4ax.com...
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

Nov 17 '05 #2
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
-------------------------------------------------------

"Amy" <am*******@mccombs.utexas.edu> wrote in message
news:gd********************************@4ax.com...
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

Nov 17 '05 #3
Context.Session[var_name]

--

Derek Davis
dd******@gmail.com

"Amy" <am*******@mccombs.utexas.edu> wrote in message
news:gd********************************@4ax.com...
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

Nov 17 '05 #4

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

Similar topics

9
by: Xizor | last post by:
Let's say I run a server. I have two people using the server. Bill and Joe. Bill is at address.com/bill and Joe is at address.com/joe. Let's say Joe and Bill are both using PHP with sessions on...
1
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
8
by: Marc Hoeve | last post by:
Hi everybody I'm setting up 2 websites for a friend of mine, en I'm have problems with one of the sites. The situation: I have 2 different domains (both in the .NL domain). Both domains...
2
by: Bonj | last post by:
H I've got the following problem - I need to have an aspx page with two frames, although the question isn't necessarily about the workings of the frames, more session variables... the frames consist...
4
by: VB Programmer | last post by:
If I have a variable I want to share in my application what is the difference between just declaring a variable (Dim strMyVar as String) and using a session variable (Session("strMyVar"))? When...
4
by: John Kraft | last post by:
Hi all, My question is more of a phylisophical one here, but I am wondering what the difference is (effectively and performance wise) between using a shared variable/static variable and using a...
2
by: Joe Molloy | last post by:
Hi, This isn't a mission critical question but I thought I'dl throw it out there for your feedback as it's a bit curious. I have developed a shopping cart for an application I'm working on...
3
by: Alan Wang | last post by:
Hi there, Once my application gets complicated and complicated. I found it's really hard to keep track of Session value I am using in my asp.net application. I am just wondering if anyone have...
2
by: DLN | last post by:
Hello all, I apologize for the naivety of this question, but I'm wondering whether session variables can ever be modified (somehow) by a client without having to go through code that I write. ...
4
by: agun | last post by:
Hi guys, Sorry for asking something that maybe already obvious to you all. But since i'm newbie, i just need further explanation. (I've read the PHP Sessions thread written by Atli) In my head,...
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
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: 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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.