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

Using Application() variables in non-web classes

Hi All,

I saved a variable to the Application() collection and I can access this
from the aspx.vb code. However, I want to be able to access this variable
from a simple class. I've seen where I can have the class inherit from one
of the web classes, but I don't want to do that just for a simple class that
needs one variable. Currently, I'm making a public property in the class and
setting it during the Application_Start() event. But I don't think this is
the best approach. Is it possible to use the Application() collection from a
simple class?

Thanks,

Brian
Nov 17 '05 #1
3 3432
You should look into:

System.Web.HttpContext.Current.Application

That will give you the application object of the current web request when
the code runs.

HTH,

bill

"Brian Bischof" <br***@nospam.bischofsystems.com> wrote in message
news:uk**************@TK2MSFTNGP12.phx.gbl...
Hi All,

I saved a variable to the Application() collection and I can access this
from the aspx.vb code. However, I want to be able to access this variable
from a simple class. I've seen where I can have the class inherit from one
of the web classes, but I don't want to do that just for a simple class that needs one variable. Currently, I'm making a public property in the class and setting it during the Application_Start() event. But I don't think this is
the best approach. Is it possible to use the Application() collection from a simple class?

Thanks,

Brian

Nov 17 '05 #2
Absolutely...

Add an import entry to the class:
System.Web.HttpContext
Either at the top of your class, or under project
properties.

Then, in your class, you reference the
Session/Application/Server etc objects via:

{System.Web.HttpContext.}Current.
{Application|Session|Server etc}

-----Original Message-----
Hi All,

I saved a variable to the Application() collection and I can access thisfrom the aspx.vb code. However, I want to be able to access this variablefrom a simple class. I've seen where I can have the class inherit from oneof the web classes, but I don't want to do that just for

a simple class that

Nov 17 '05 #3
Thanks for the quick response. It works great!

Brian

"William F. Robertson, Jr." <wf*********@kpmg.com> wrote in message
news:Ob**************@TK2MSFTNGP12.phx.gbl...
You should look into:

System.Web.HttpContext.Current.Application

That will give you the application object of the current web request when
the code runs.

HTH,

bill

"Brian Bischof" <br***@nospam.bischofsystems.com> wrote in message
news:uk**************@TK2MSFTNGP12.phx.gbl...
Hi All,

I saved a variable to the Application() collection and I can access this
from the aspx.vb code. However, I want to be able to access this variable from a simple class. I've seen where I can have the class inherit from one of the web classes, but I don't want to do that just for a simple class that
needs one variable. Currently, I'm making a public property in the class

and
setting it during the Application_Start() event. But I don't think this is the best approach. Is it possible to use the Application() collection

from a
simple class?

Thanks,

Brian


Nov 17 '05 #4

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

Similar topics

15
by: lawrence | last post by:
Sorry for the dumb question but I'm new to Javascript. I wrote this script hoping to animate some div blocks on a page. You can see the page here: http://www.keymedia.biz/demo.htm Can anyone...
8
by: Sergio Otoya | last post by:
Hi all, I need to add an input hidden field to an existing form (post). I have tried a couple things like adding the '<INPUT type=hidden name=idSelectedURL value=http://server/documents>' to...
1
by: Roi | last post by:
Hello, I'm trying to implements Factory Patern using 2 DLL's. On the first DLL i implemented the Factory, and on the other I defines global variables which activating the Factory. the...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
11
by: Timothy Shih | last post by:
Hi, I am having a freezing issue with my application. My application serves several remotable objects, all of which must be initialized before their use. Furthermore, some of them depend on each...
0
by: Shiraz | last post by:
Hi I have a question regarding the functionality of merge modules. Since this relates to my previous queries, I'll just give you a brief background on the topic. I had to make an installer for...
1
by: APA | last post by:
In the Application_Start event I load several static variables with data from the database that are critical to the execution of the application. My question is that during app start if a second...
13
by: Albert | last post by:
Hi I'm using the lcc compiler for win32. I tried compiling a program but there's an error stating: "cpp: Can't open input file clrscr()" I don't get it - I've included <tcconio.h>. (strange why...
5
by: YouPoP | last post by:
I have an MFC application (VS2005) with splitter window (one is the view other is a formview). you can select from the main menu different math operation on polynoms and polynoms shows on the...
5
by: raylopez99 | last post by:
I have a form, Form6, that has a bunch of buttons overlaid on it. I want to be able to click on any arbitrary area of the form, and if that area of the form is overlaid by a button, I want to...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.