Share via


WebPart.OnUnload Method

The event handler for the System.Web.UI.Control.Unload event, which occurs when the Web Part is being unloaded from memory.

Namespace:  Microsoft.SharePoint.WebPartPages
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

Syntax

'Declaration
Protected Overrides Sub OnUnload ( _
    e As EventArgs _
)
'Usage
Dim e As EventArgs

Me.OnUnload(e)
protected override void OnUnload(
    EventArgs e
)

Parameters

  • e
    Type: System.EventArgs

    A System.EventArgs object that contains data for the System.Web.UI.Control.Unload event.

Remarks

If your Web Part needs to perform any final cleanup before closing, such as closing files, closing database connections, and discarding objects, you can subscribe to the System.Web.UI.Control.Unload event by adding an appropriate event handler to the Web Part constructor. For example:

this.Unload += new EventHandler (MyUnloadHandler);

See Also

Reference

WebPart Class

WebPart Members

Microsoft.SharePoint.WebPartPages Namespace