Hi,
The function is only available while that page (class) is loaded, which
is only while the page is being requested.
Actually, a Page is an object like any other. "loaded" is a bit confusing
in this context.
When the request arrives, an instance of the corresponding Page is
created. The instance is disposed after the Response is sent. On the next
Request, another, brand new instance of the Page is created. This explains
why you cannot save instance variables over requests, but must resort to
Session, Cache, Application objects...
However, if you have a public method in a class deriving from Page, you
can use that method at any time simply by creating a new instance of that
Page:
MyOwnPage anInstance = new MyOwnPage();
anInstance.executeSomething();
However, I wouldn't recommend this. If you have a public method that is
used in multiple pages, extract this method to a different object and use
that object from all pages. It's all abut design ;-)
HTH,
Laurent
You could place a function like this (along with other functions you wish
to call repeatedly) in their own assembly (.dll) and then just reference
that assembly from your ASP.NET project, make an instance of the class
that contains them and run them as you need to.
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog:
http://www.galasoft-LB.ch
PhotoAlbum:
http://www.galasoft-LB.ch/pictures
Support children in Calcutta:
http://www.calcutta-espoir.ch