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

Using Session, Response etc. in a class

Hi,

I'm building an ASP .NET application. I have a routine to
check some info in an object stored in a Session variable.

As it is, I have to duplicate this code in every page.

Is there any way to build a class which can access the
info stored in a session variable?

I would like to build a class containing methods, which I
can call from my web pages. This class will read, for
instance, Session("info"), and perform some routines
based on the data.

I can build the class, and make it
inherit "System.Web.UI.Page", in order to get this
functionality, but is there no better way? There really
seems to be no need to inherit all the functionality of a
page (it clutters Intellisense, if nothing else)!?

Any help is appreciated.

Regards,
Jakob
Nov 17 '05 #1
1 1064
Hi Kevin,

That was a big help -- thanks alot!!

Regards,
Jakob
-----Original Message-----
You can grab all objects that are available in a Page from the CurrentHttpContext. Example:

Dim objSession as System.Web.SessionState.HttpSessionState =System.Web.HttpContext.Current.Session

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Jakob Bengtsson" <j.*********@email.dk> wrote in message
news:0b****************************@phx.gbl...
Hi,

I'm building an ASP .NET application. I have a routine to check some info in an object stored in a Session variable.
As it is, I have to duplicate this code in every page.

Is there any way to build a class which can access the
info stored in a session variable?

I would like to build a class containing methods, which I can call from my web pages. This class will read, for
instance, Session("info"), and perform some routines
based on the data.

I can build the class, and make it
inherit "System.Web.UI.Page", in order to get this
functionality, but is there no better way? There really
seems to be no need to inherit all the functionality of a page (it clutters Intellisense, if nothing else)!?

Any help is appreciated.

Regards,
Jakob

.

Nov 17 '05 #2

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

Similar topics

3
by: PM | last post by:
I'm trying to make a kind of search history containing the 3 last searched words. So I'm using 3 Session Variables: Word1 / Word2 / Word3. In order to get this history working, I need to put the...
0
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
8
by: FS Liu | last post by:
Hi, I am writing ATL Service application (XML Web service) in VS.NET C++. Are there any sample programs that accept XML as input and XML as output in the web service? Thank you very much.
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...
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...
6
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
Greetings! I was researching AJAX to provide a solution to displaying status messages while a long process executed. I found several examples online and was able to use their code to get a quick...
3
by: judge82 | last post by:
I am learning how to use servlet, I want create a session that when one logs in it will say "weclome 'username'" in the welcome page the first code I wrote (first below), when i click submit it...
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...
1
by: creative1 | last post by:
When I test the application I get follwowing error: could not connect to smtp host: connection timeout error can someone please check if I have rigth settings? Where I am wrong here Is IP and...
8
by: inpuarg | last post by:
I 'm developing a c# (.net 2.0) windows forms application and in this application i want to connect to a java servlet page (HTTPS) (which is servlet 2.4 and which may be using Web Based SSO Sun...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.