getting the application state object.

G

Guest

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
 
H

Hermit Dave

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top