By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,192 Members | 1,779 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,192 IT Pros & Developers. It's quick & easy.

Accessing Instance Class and Variables accross entire application

P: n/a
I am programming ASP.NET using C#.

I have been accessing static variables accross my entire application but now
need to change some of the static variables that are session specific to
instance variables.
(For more background, see previous post about 30 min ago)

It was so cool using static variables because they where global to the
entire application so I could calculate them when the page loaded and use
then anywhere in the app. Now I need to use instance variables so that there
will not be session conflicts but would still like to be able to access
those instance variables from anywhere. Is there a way of doing this?

Since my app always loads the same page and then loads user controls to
change pages, I can instance a class in the default.aspx page and set its
variables (properties or fields) for that page load. The question is how do
I make that instanced class and its members accessable to all other pages
within my application?

I suppose a session variable may be an option, but that seems less then
ideal...

Thanks for your help

Earl
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
> I suppose a session variable may be an option, but that
seems less then ideal...


Why does that seem less than ideal? The session object is there to handle
session information. That is exactly what you want.

-JG
Nov 15 '05 #2

P: n/a
I guess I was hoping for a C# language way of doing this rather then an
ASP.NET way since this is such a core part of the application. On thing I
don't like about using a session variable is that it holds the object in
memory until it times out at the set timeout interval. Instance objects, on
the other hand, are passed to the garbage collector or destruction as soon
as they go out of scope. This meens that they are not wasting resources
hanging around in memory. Maybe I should look into a way of destroying the
session object once the page has loaded???

I could use C# to pass the variables from method to method but this gets to
be a mess also. (tons of passing variables)

Earl

"Juan Gabriel Del Cid" <jd*****@atrevido.nospam.net> wrote in message
news:OT**************@tk2msftngp13.phx.gbl...
I suppose a session variable may be an option, but that
seems less then ideal...


Why does that seem less than ideal? The session object is there to handle
session information. That is exactly what you want.

-JG

Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.