Occurs during the process of removing a WebPart control (or server or user control) from a page.
Assembly: System.Web (in System.Web.dll)
The event is raised by the OnWebPartClosing method when the WebPartManager control is in the process of closing a control. If the removal of the control is successful, this event is followed by the WebPartClosed event.
Page developers can provide a custom handler for the event by adding the OnWebPartClosed attribute to the <asp:webpartmanager> element in a page, and assigning a custom method name to the attribute.
Normally, when the event is raised as a direct result of a user closing a WebPart control, the event can be cancelled. However, there is a scenario in which the event cannot be cancelled. If a WebPartZone control is deleted, the WebPart controls it contains must all be closed, otherwise they would be orphaned. In this case the WebPartManager control closes the WebPart controls, not the user. And when the WebPartManager control is in the process of calling the CloseWebPart method to close each control, and the event is raised, the event cannot be cancelled (by design) because the WebPartManager needs to complete the task of cleaning up all the zone's controls.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.