Share via


OnUnload(System.EventArgs) Method

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

Parameters

e   A System.EventArgs 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's constructor. For example:

this.Unload += new EventHandler (MyUnloadHandler);

Requirements

Platforms: Windows Server 2003

Security: Code Access Security