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.

 

 

 

 

 

 

 

Sys.Net.WebRequest remove_completed Method

Removes the event handler added by the add_completed method.

Syntax

MyWebRequest.remove_completed();

Remarks

The executor associated with the request is responsible for raising the event by calling the completed method. The event handler is called when the associated executor finishes its work. An executor finishes its work in one of three states: completed, aborted, or timed out.

Example

The following example shows how to add and remove the completed event handler. This code is part of a complete example found in the WebRequest class overview.

javascript

// This function adds and removes the 
// Web request completed event handler.
function WebRequestCompleted()
{    
    // Instantiate the WebRequest.
    var wRequest =  new Sys.Net.WebRequest();

    // Set the request Url.  
    wRequest.set_url(getPage);  

    // Set the web request completed event handler,
    // for processing return data.
    wRequest.add_completed(OnWebRequestCompleted);   
    alert("Added Web request completed handler");

    // Remove the web request completed event handler.
    // Comment the following two lines if you want to
    // use the handler.
    wRequest.remove_completed(OnWebRequestCompleted); 
    alert("Removed handler; the Web request return is not processed.");

    // Execute the request.
    wRequest.invoke();  
}