ScriptManager.RegisterDispose Method

Registers a dispose script for a control that is inside an UpdatePanel control. The script is executed when the UpdatePanel control is updated or deleted.

Namespace:  System.Web.UI
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

public void RegisterDispose(
	Control control,
	string disposeScript
)

Parameters

control
Type: System.Web.UI.Control

The control that the dispose script is for.

disposeScript
Type: System.String

The dispose script.

ExceptionCondition
ArgumentNullException

control is null.

- or -

disposeScript is null.

ArgumentException

control is not found on the page.

- or -

control is not inside an UpdatePanel control.

Use the RegisterDispose method to register dispose scripts for controls that are inside an UpdatePanel control. During asynchronous postbacks, UpdatePanel controls can be updated, deleted, or created. When a panel is updated or deleted, any dispose scripts that are registered for controls that are inside the UpdatePanel are called. In typical page development scenarios, you do not have to call the RegisterDispose method.

The RegisterDispose method is intended for use by control developers to register script or create controls that inherit from the IScriptControl interface. For example, you might use a dispose script if you develop a client control by using composition. In your control, you implement IScriptControl and render individual controls. You register the dispose method of any item that does not correspond to a defined client component such as Sys.TextBox. If your custom control composes elements that correspond to client components in the Microsoft Ajax Library, you do not have to register a dispose script, because dispose is called automatically. Therefore, use the RegisterDispose method for client components that are part of the Microsoft Ajax Library and that have to free resources when a component is no longer used.

The RegisterDispose method can be called multiple times for a control. Multiple scripts are aggregated. The order of disposing scripts matches the order in which the scripts were registered.

If you register a dispose script for a control that is not in an UpdatePanel control, an exception is thrown. The dispose script is called between the pageLoading and pageLoaded events of the PageRequestManager class.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft