The Application object provides the init, load, and unload events, and it inherits the disposing and propertyChanged events from the base Component class. All of these events apply to the life cycle of the client application in the browser.
If partial-page rendering is supported and the page contains an UpdatePanel control, the PageRequestManager class provides additional events that apply to the parts of the page that are rendered asynchronously. For more information about partial-page rendering, see Partial-Page Rendering Overview.
Individual components can expose events that apply only to the component. They can also access application-level events by using the Application object.
In most cases, page developers should put their code in the load event. At that point in the page life cycle, all scripts are loaded and all components have been created and ready to use. Any code that is included in a function named pageLoad will automatically run when the page loads.
Component developers can access other events or bind additional handlers to the load or unload events by invoking the event's add_ accessor method and passing the handler function. The following example shows how to bind a function named myUnloadHandler to the unload event.
Sys.Application.add_unload(myUnloadHandler)
When an event and its handlers are no longer needed, you can call the remove_ accessor method, as in the following example:
Sys.Application.remove_unload(myUnloadHandler);
You can attach additional handlers to an event by calling the add_ accessor one time for each handler. Handlers are removed individually by calling the remove_ accessor method.
For more information about the Sys.Application events, see AJAX Client Life-Cycle Events.
In most scenarios, you should add components to an application by using the $create command. After a component has been registered with the application, you can access it in the application by calling the findComponent method or the $find shortcut. You can get a list of all available components by calling the getComponents method.
For more information about how to develop components, controls, and behaviors, see Adding AJAX Functionality to ASP.NET Controls.
If you reference a standalone script file (.js file) for use with partial-page rendering, the code in the script file must call the notifyScriptLoaded method. This notifies the application that the script has finished loading. For more information, see Sys.Application.notifyScriptLoaded Method.