Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.

 

 

 

 

 

 

 

Skip Navigation Links.
Tutorials
Sample ASP.NET AJAX Application
ASP.NET AJAX and JavaScript
Extending JavaScript with ASP.NET AJAX
Creating Custom Client Script in ASP.NET AJAX
Dynamically Assigning ASP.NET AJAX Script References
Globalizing a Date by Using Client Script
Embedding a JavaScript File as a Resource in an Assembly
Embedding Localized Resources for a JavaScript File
Adding Localized Resources to a JavaScript File
Creating Custom Client Events
The UpdatePanel Control
Introduction to the UpdatePanel Control
Creating a Simple ASP.NET Page with Multiple UpdatePanel Controls
Using the UpdatePanel Control with Data-Bound Controls
Using the UpdatePanel Control with Master Pages
Using the UpdatePanel Control with User Controls
Using the UpdatePanel Control with a Web Service
Customizing Error Handling for UpdatePanel Controls
Animating UpdatePanel Controls
Canceling an Asynchronous Postback
Giving Precedence to a Specific Asynchronous Postback
Working with PageRequestManager Events
The UpdateProgress Control
Introduction to the UpdateProgress Control
Programming UpdateProgress Controls in Client Script
The Timer Control
Introduction to the Timer Control
Using the Timer Control with Multiple UpdatePanel Controls
ASP.NET Application Services
Using Forms Authentication
Using Profile Information
Web Services
Exposing Web Services to Client Script
Calling Web Services from Client Script
ASP.NET AJAX Extensibility
Creating Custom ASP.NET AJAX Non-Visual Client Components
Creating Custom ASP.NET AJAX Client Controls
Creating an Extender Control
Adding Client Capabilities to a Web Server Control
Creating a Client Component Class Using the Prototype Model
Defining Custom Component Properties and Raising PropertyChanged Events
Releasing Component Resources

Releasing Component Resources

Introduction

Your custom client component such as a behavior, control, or base component might have to release resources before the component is disposed. If it does, you can override the Sys.Component.dispose method and release the resources in the overridden method. This makes sure that the resources are released immediately before the component is disposed. Your component inherits the dispose method from the Sys.Component, Sys.UI.Behavior, or Sys.UI.Control base class, depending on the component's base type.

In your component's dispose method, follow these steps:

  • Dispose or reset any resources used by the component.

  • Stop any processes that the component might queue internally, and disable any functionality that might be called by the component consumer.

  • Invoke the method of the base class.

    note

    It is useful to provide a public property that indicates the component's enabled status and that raises a property-changed event in its set accessor. Then in the dispose method, set the property to indicate that the component is disabled. This enables a page developer to detect the availability of the component.

The following example show how to override the dispose method that is defined in the prototype of a component class.

dispose: function() {
    // Call set_enabled so the property-changed event is raised 
    //  in order to notify any attached listeners.
    this.set_enabled(false);

    // Stop any component processes so that 
    // they are not called after disposal.
    this._stopSimpleComponentProcesses();

    // Call the base dispose method.
    Samples.SimpleComponent.callBaseMethod(this, 'dispose');
}

The component in this example provides an enabled property that is set to false in the dispose method. The enabled property's set accessor method raises a property-changed event that a page developer can bind to, which enables the developer to test the component's availability. This component also has a private _stopSimpleComponentProcess method that is responsible for stopping any queued process that could still raise a tick event. The method also disables functionality that might be invoked by the component consumer. As a last task, the base dispose method is called by invoking the inherited Type.callBaseMethod method.

note

All registered classes inherit the callBaseMethod method. For more information, see callBaseMethod Method.