Ask a Question related to ASP.NET General, Design and Development.
-
Brian Bischof #1
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
Brian Bischof Guest
-
#39044 [NEW]: Changing a static variables in a class changes it across sub/super classes.
From: matti at nitro dot fi Operating system: * PHP version: 5.1.6 PHP Bug Type: Scripting Engine problem Bug description: ... -
Classes and declaring variables
Greetings, all! I have a question about classes and variables. When you are working with a class, when should you (or are required) to declare... -
Global variables - application variables vs include file
What are the best methods for using global constants and variables? I've noticed that many people put all global constants in a file and include... -
Variables in classes
How can I pass a variable out of a class? I'm sure this is very simple, but I can't find out how. I think you put a charater in front of the... -
Problems using application state with custom classes
I am working with vb.net in a asp.net application. I have created a config file in xml format. The goal is to be able to change the config file... -
William F. Robertson, Jr. #2
Re: Using Application() variables in non-web classes
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" <brian@nospam.bischofsystems.com> wrote in message
news:ukudZXZQDHA.2320@TK2MSFTNGP12.phx.gbl...that> 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 classand> needs one variable. Currently, I'm making a public property in the classa> 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> simple class?
>
> Thanks,
>
> Brian
>
>
William F. Robertson, Jr. Guest
-
David Waz... #3
Using Application() variables in non-web classes
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}
can access this>-----Original Message-----
>Hi All,
>
>I saved a variable to the Application() collection and Iaccess this variable>from the aspx.vb code. However, I want to be able toinherit from one>from a simple class. I've seen where I can have the classa simple class that>of the web classes, but I don't want to do that just for
David Waz... Guest
-
Brian Bischof #4
Re: Using Application() variables in non-web classes
Thanks for the quick response. It works great!
Brian
"William F. Robertson, Jr." <wfrobertson@kpmg.com> wrote in message
news:ObIeBbZQDHA.1712@TK2MSFTNGP12.phx.gbl...variable> 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" <brian@nospam.bischofsystems.com> wrote in message
> news:ukudZXZQDHA.2320@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 thisone> > from a simple class. I've seen where I can have the class inherit fromis> that> > of the web classes, but I don't want to do that just for a simple class> and> > needs one variable. Currently, I'm making a public property in the class> > setting it during the Application_Start() event. But I don't think thisfrom> > the best approach. Is it possible to use the Application() collection> a>> > simple class?
> >
> > Thanks,
> >
> > Brian
> >
> >
>
Brian Bischof Guest



Reply With Quote

