Compartilhar via


SPWebPartManager.SPConnectWebParts Method (WebPart, ProviderConnectionPoint, WebPart, ConsumerConnectionPoint)

Creates a SPWebPartConnection between two Web Parts with the references to the specified Web Parts and the specified ConnectionPoint objects.

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

Syntax

'Declaration
Public Function SPConnectWebParts ( _
    provider As WebPart, _
    providerConnectionPoint As ProviderConnectionPoint, _
    consumer As WebPart, _
    consumerConnectionPoint As ConsumerConnectionPoint _
) As SPWebPartConnection
'Usage
Dim instance As SPWebPartManager
Dim provider As WebPart
Dim providerConnectionPoint As ProviderConnectionPoint
Dim consumer As WebPart
Dim consumerConnectionPoint As ConsumerConnectionPoint
Dim returnValue As SPWebPartConnection

returnValue = instance.SPConnectWebParts(provider, _
    providerConnectionPoint, consumer, _
    consumerConnectionPoint)
public SPWebPartConnection SPConnectWebParts(
    WebPart provider,
    ProviderConnectionPoint providerConnectionPoint,
    WebPart consumer,
    ConsumerConnectionPoint consumerConnectionPoint
)

Parameters

Return Value

Type: Microsoft.SharePoint.WebPartPages.SPWebPartConnection
The connection between the two Web Parts.

Exceptions

Exception Condition
WebPartPageUserException
  1. Both providerConnectionPoint and consumerConnectionPoint are Windows SharePoint Services 2.0 connection interfaces.

  2. The consumer or provider Web Part is closed.

  3. The providerConnectionPoint or consumerConnectionPoint cannot participate in connection.

  4. Multiple connections are attempted on the providerConnectionPoint or consumerConnectionPoint and the connection does not support multiple connections.

  5. The consumerConnectionPoint and providerConnectionPoint interfaces are not the same type and a transformer was either not provided or the transformer does not support the interface types required by the providerConnectionPoint or the consumerConnectionPoint.

InvalidOperationException

The provider or consumer Web Part is not in a zone.

Remarks

This overload is used to connect Web Parts when their connection points are sufficiently compatible that they can connect without using a WebPartTransformer object.

See Also

Reference

SPWebPartManager Class

SPWebPartManager Members

SPConnectWebParts Overload

Microsoft.SharePoint.WebPartPages Namespace