Monday, March 26, 2012

Setting Session within Method?

Needless to say I'm new to .Net. I'm trying to set Session variables
from within a method within a class.

(Name "Session" is not declared) is the message I get while typing in
the code. I don't get this while entering code within an .aspx.vb file.
Obviously I need to create and instance of some System.Web... object but
I don't know what it is. Any ideas?

Also by setting session variables from within the class and not sending
back values by properties, is this breaking some object oriented
concept?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!Simply use the full namespace from within your class:
System.Web.HttpContext.Current.Session

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
Developer for Hire

"thdevdex" <thdevdex@.dbcoders.com> wrote in message
news:%23oc4zzdZDHA.2256@.TK2MSFTNGP10.phx.gbl...
> Needless to say I'm new to .Net. I'm trying to set Session variables
> from within a method within a class.
> (Name "Session" is not declared) is the message I get while typing in
> the code. I don't get this while entering code within an .aspx.vb file.
> Obviously I need to create and instance of some System.Web... object but
> I don't know what it is. Any ideas?
> Also by setting session variables from within the class and not sending
> back values by properties, is this breaking some object oriented
> concept?
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
Simply use the full namespace from within your class:
System.Web.HttpContext.Current.Session

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
Developer for Hire

"thdevdex" <thdevdex@.dbcoders.com> wrote in message
news:%23oc4zzdZDHA.2256@.TK2MSFTNGP10.phx.gbl...
> Needless to say I'm new to .Net. I'm trying to set Session variables
> from within a method within a class.
> (Name "Session" is not declared) is the message I get while typing in
> the code. I don't get this while entering code within an .aspx.vb file.
> Obviously I need to create and instance of some System.Web... object but
> I don't know what it is. Any ideas?
> Also by setting session variables from within the class and not sending
> back values by properties, is this breaking some object oriented
> concept?
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
I added that and it works fine, thanks. One more question.

I normally try to get answers from the VS2003 documentation and when I
was researching which object to use, the documentation for Session was
yapping about the HttpSessionState object. Is there a recommended area
within the documentation to figure out the appropriate system objects to
use and when?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
I added that and it works fine, thanks. One more question.

I normally try to get answers from the VS2003 documentation and when I
was researching which object to use, the documentation for Session was
yapping about the HttpSessionState object. Is there a recommended area
within the documentation to figure out the appropriate system objects to
use and when?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

0 comments:

Post a Comment