You can implement two page-level event methods, OnStartPage and OnEndPage, in your component. These methods are optional. Active Server Pages will work with any Automation component, regardless of whether these methods are implemented.
When the server creates a component instance, it looks for OnStartPage and OnEndPage methods associated with that componentís IDispatch interface. If the component has implemented these methods, the server will automatically call the OnStartPage method during script processing before the component is used and call the OnEndPage method when all scripts on the ASP page have been processed.
The only exceptions are components created with application scope, which never receive OnStartPage or OnEndPage method calls. For more information about application-scope objects, see the Global.asa Reference.
Because application-scope objects do not receive a call to OnStartPage, they cannot depend on its functionality.
It is recommended that your server component, regardless of scope, handle the situation in which the OnStartPage method fails or is not called. A common example of the latter is the case where your component is created by some method other than the Server.CreateObject method provided by ASP.
© Microsoft Corporation. All rights reserved.