473,385 Members | 1,587 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.

getting the application state object.

Hi,

I have setup my asp.net app so that i have one globalobject that contains
all information for my application. I am trying to work out the best way to
implement the applicationstate object with my variables.

Would i get the object from the applicationstate on page_load? and then keep
the global variable in memory until a button is clicked or a certain event
takes place? But i dont know how to acess this variable if it is created in
the page_load function:

private sub page_load()
dim cf as MyGlobalFunctions
cf = application.Get("common")

cf.DoSomething()
end sub

private sub anotherButton_click()
'i cant access cf in here! how do i do this?
end sub

If this is similar to how you do it, then when do i add the cf object back
to the application state?

Application("common") = cf

because i cant do it on the anotherButton_click() function......

I was thinkin of another way to do it would be to dim the global object, get
it from appstate, and then add it back to appstate after change is made on
all event functions. This would work but it means i am creating so many of
the same object within a page....

How is the best way to do this?

Thanks
Nov 18 '05 #1
2 1137
you will have to clear CF as private member of that class.

if the snippet that you posted cf is declared as a local variable to
Page_load method. Which means that that variable will be cleaned up once the
method has finished.

if you declared it as a private variable of the class then it will be
accessible to all methods.

you class alternatively could have a static variable which means that the
individual class dont need to call new instead can user class.Methodname to
call it

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Joshua Weir" <Jo********@discussions.microsoft.com> wrote in message
news:C2**********************************@microsof t.com...
Hi,

I have setup my asp.net app so that i have one globalobject that contains
all information for my application. I am trying to work out the best way to implement the applicationstate object with my variables.

Would i get the object from the applicationstate on page_load? and then keep the global variable in memory until a button is clicked or a certain event
takes place? But i dont know how to acess this variable if it is created in the page_load function:

private sub page_load()
dim cf as MyGlobalFunctions
cf = application.Get("common")

cf.DoSomething()
end sub

private sub anotherButton_click()
'i cant access cf in here! how do i do this?
end sub

If this is similar to how you do it, then when do i add the cf object back
to the application state?

Application("common") = cf

because i cant do it on the anotherButton_click() function......

I was thinkin of another way to do it would be to dim the global object, get it from appstate, and then add it back to appstate after change is made on
all event functions. This would work but it means i am creating so many of
the same object within a page....

How is the best way to do this?

Thanks

Nov 18 '05 #2
my bad,

i meant
you will have to declare CF as a data member of the codebehind class.

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:#B*************@TK2MSFTNGP11.phx.gbl...
you will have to clear CF as private member of that class.

if the snippet that you posted cf is declared as a local variable to
Page_load method. Which means that that variable will be cleaned up once the method has finished.

if you declared it as a private variable of the class then it will be
accessible to all methods.

you class alternatively could have a static variable which means that the
individual class dont need to call new instead can user class.Methodname to call it

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Joshua Weir" <Jo********@discussions.microsoft.com> wrote in message
news:C2**********************************@microsof t.com...
Hi,

I have setup my asp.net app so that i have one globalobject that contains all information for my application. I am trying to work out the best way

to
implement the applicationstate object with my variables.

Would i get the object from the applicationstate on page_load? and then

keep
the global variable in memory until a button is clicked or a certain event takes place? But i dont know how to acess this variable if it is created

in
the page_load function:

private sub page_load()
dim cf as MyGlobalFunctions
cf = application.Get("common")

cf.DoSomething()
end sub

private sub anotherButton_click()
'i cant access cf in here! how do i do this?
end sub

If this is similar to how you do it, then when do i add the cf object back to the application state?

Application("common") = cf

because i cant do it on the anotherButton_click() function......

I was thinkin of another way to do it would be to dim the global object,

get
it from appstate, and then add it back to appstate after change is made on all event functions. This would work but it means i am creating so many of the same object within a page....

How is the best way to do this?

Thanks


Nov 18 '05 #3

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

Similar topics

4
by: BB | last post by:
Hello all, I might be missing something here, but am trying to understand the difference between using application-level variables--i.e. Application("MyVar")--and global variables--i.e. public...
8
by: Vishwanathan Raman | last post by:
Hi I have a declared a static DataSet object SOBJ in Global.asax.I also have a localy defined DataSet LSOBJ in Global.asax which I am storing in Application State.Is there any technical...
1
by: Nathan Sokalski | last post by:
I have retrieved data from a database using a SELECT statement that includes an INNER JOIN. The data seems to be retrieved to the DataSet OK, but I am having trouble getting the data from the...
1
by: Nathan Sokalski | last post by:
I have retrieved data from a database using a SELECT statement that includes an INNER JOIN. The data seems to be retrieved to the DataSet OK, but I am having trouble getting the data from the...
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: 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:
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
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.