473,387 Members | 1,485 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,387 software developers and data experts.

Using Session in a class

I have created several forms with procedures that I want to move to a class
so it can be used by other forms, but get an error when I move the Session
commands; e.g., Session("Mode")="Add"

How can I use Session in a class procedure.
Nov 19 '05 #1
3 1152
HttpContext.Current.Session

Note however that HTtpContext.Current will be null if not in the a web
request context, safe programming would be:

dim context as HttpContext = HttpContext.Current
if context is nothing then
throw new ApplicationException("Must be used from within web context")
'or deal with it some other way
end if

dim session as HttpSessionState = context.Session
'can use session from here on end.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Rock" <ro********@yahoo.com> wrote in message
news:uZ**************@TK2MSFTNGP11.phx.gbl...
I have created several forms with procedures that I want to move to a class so it can be used by other forms, but get an error when I move the Session
commands; e.g., Session("Mode")="Add"

How can I use Session in a class procedure.

Nov 19 '05 #2
try this way,

httpcontext.current.session("mode")

--
-Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com

"Rock" <ro********@yahoo.com> wrote in message
news:uZ**************@TK2MSFTNGP11.phx.gbl...
I have created several forms with procedures that I want to move to a class so it can be used by other forms, but get an error when I move the Session
commands; e.g., Session("Mode")="Add"

How can I use Session in a class procedure.

Nov 19 '05 #3
Thanks, all, very good advice, this works much better.

"Rock" <ro********@yahoo.com> wrote in message
news:uZ**************@TK2MSFTNGP11.phx.gbl...
I have created several forms with procedures that I want to move to a class so it can be used by other forms, but get an error when I move the Session
commands; e.g., Session("Mode")="Add"

How can I use Session in a class procedure.

Nov 19 '05 #4

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

Similar topics

2
by: Jon Dellaria | last post by:
I have been using MySql as the database using JSP's and JavaBeans but recently I have wanted to start using the database connection pooling mechanism built into TomCat. I think I am having a...
4
by: Kevin Phifer | last post by:
Ok, before anyone freaks out, I have a solution I need to create that gathers content from maybe different places. Each one can return a <form> in the html, so its the classic can't have more than...
1
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
5
by: Åženol Akbulak | last post by:
Hello; I use in my web application FormsAuthentication. Also I use Session state (InProc). When a user logged in, I can read Session parameters. (For example Session). Problem is that, when...
15
by: Joe Fallon | last post by:
I would like to know how you can figure out how much memory a given instance of a class is using. For example, if I load a collection class with 10 items it might use 1KB, and if I load it with...
13
by: | last post by:
Simple question, I think... I'm storing an object in the Session object. In the code behind I read that object: trx = CType(Session("Transaction"), BOCSTransaction) If I change any...
1
by: mabra | last post by:
Hi All ! Sorry for my crossposting, I am not completely sure about which group is really of any help. I started using the WUA COM API from C#. I created an interop assembly and my code compiles...
9
by: viz | last post by:
hi, i have written a class for session handling, and i want to use it to keep track of the user. After authenticating the user in login page i am storing the session info like uname etc.. in a...
0
by: Eugene Anthony | last post by:
The problem with my coding is that despite removing the records stored in the array list, the rptPages repeater control is still visible. The rptPages repeater control displayes the navigation...
10
by: marting | last post by:
Before I throw my new expensive laptop out of the window! I'm stuck on getting my joins right with the correct amount in a column count. After speaking with someone a few weeks back, they...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.