Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

WebPartManager.WebPartsDisconnecting Event

Occurs during the process of ending the connection between previously connected WebPart or server controls.

Namespace:  System.Web.UI.WebControls.WebParts
Assembly:  System.Web (in System.Web.dll)
public event WebPartConnectionsCancelEventHandler WebPartsDisconnecting
<asp:WebPartManager OnWebPartsDisconnecting="WebPartConnectionsCancelEventHandler" />

The WebPartsDisconnecting event is raised by the OnWebPartsDisconnecting method, and it signals the fact that a user has clicked a disconnect verb, or the DisconnectWebParts method has otherwise been called. The event provides an opportunity to cancel the process of ending a connection before it is complete. If the connection is ended successfully, this event is followed by the WebPartsDisconnected event.

Page developers can add a custom handler for the event by adding the OnWebPartsDisconnecting attribute to the <asp:webpartmanager> element, and assigning a custom method name to the attribute.

Normally, when the WebPartsDisconnecting event is raised as a direct result of a user's action that ends a connection, the event can be cancelled. However, there are several scenarios in which the event cannot be cancelled. The first scenario is, 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 it must also be able to terminate the connections of any connected controls without any chance of interruption, so that it can complete the process of cleaning up and closing all the controls. Therefore, by design the WebPartsDisconnecting method cannot be cancelled in this scenario. For a related event that can be cancelled, see the WebPartClosing event.

The second scenario in which the WebPartsDisconnecting event cannot be cancelled is when the ActivateConnections method is called (this called during each request to a page, for example), and there is some type of conflict in the existing connections on a page. For example, perhaps a user connects control x to control y, but a shared user connects control x to control z, and yet control x is not allowed to form multiple connections. In this case, the individual user's settings for the connection take precedence, and the WebPartManager control resolves the conflict by calling the DisconnectWebPart method and ending the connection between x and z for the particular user. Because this disconnection is essential to resolving the conflict, by design the WebPartsDisconnecting event cannot be cancelled in this scenario.

The third scenario in which the WebPartsDisconnecting method cannot be cancelled is when a WebPart or server control that is currently connected is either deleted or closed. Because the control is definitely going to be removed from the page, it is a logical necessity to remove its connection. Therefore, when the WebPartManager control invokes the DisconnectWebPart method, which in turn raises the WebPartsDisconnecting event, by design there is no possibility of canceling the event.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows Phone 8.1, Windows Phone 8, 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.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.