Export (0) Print
Expand All
Expand Minimize

WebPart.PartCommunicationConnect Method

NOTE: This API is now obsolete.

Used to notify a Web Part that it has been connected to another Web Part.

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

[ObsoleteAttribute("Use ConnectionProvider or ConnectionConsumer attribute to create ConnectionPoint instead.")]
public virtual void PartCommunicationConnect(
	string interfaceName,
	WebPart connectedPart,
	string connectedInterfaceName,
	ConnectionRunAt runAt
)

Parameters

interfaceName
Type: System.String

Specifies the name of the interface on this Web Part that is being connected.

connectedPart
Type: Microsoft.SharePoint.WebPartPages.WebPart

A WebPart that specifies the other Web Part that is being connected to.

connectedInterfaceName
Type: System.String

Specifies the name of the interface that is being connected to on the other Web Part.

runAt
Type: Microsoft.SharePoint.WebPartPages.Communication.ConnectionRunAt

A ConnectionRunAt value that specifies where the interface on this Web Part should run.

A Web Part that implements a connection interface should override the PartCommunicationConnect method. This method is called by the Web Part infrastructure to notify the Web Part that it is connected during the Microsoft ASP.NET System.Web.UI.Control.PreRender event. Relevant information is passed to the connecting Web Part such as the interface it is connected over, the Web Part it is being connected to, and where the part will be running, either client-side or server-side.

If the Web Part that is being connected to is on another page, connectedPart is a null reference (Nothing in Visual Basic).

The following code example shows an overridden PartCommunicationConnect method. This code example is part of a larger example provided for the ICellProvider interface.

Because this example uses the Microsoft.SharePoint.Utilities.SPEncode class, it requires a using directive (Imports in Visual Basic) for the Microsoft.SharePoint.Utilities namespace.

For an overview of the steps of creating a connectable Web Part, see Walkthrough: Creating Connectable Web Parts in SharePoint Foundation.

// Step #7: Override the PartCommunicationConnect() method.
// The PartCommunicationConnect method is called by the Web Part infrastructure to notify the Web Part that it
// is connected during the ASP.NET PreRender event. Relevant information is passed to the part such as 
// the interface it is connected over, the Web Part it is being conected to, and where the part will be running, 
// either client-side or server-side. 
// <param name="interfaceName">Friendly name of the interface that is being connected</param>
// <param name="connectedPart">Reference to the other Web Part that is being connected to</param>
// <param name="connectedInterfaceName">Friendly name of the interface on the other Web Part</param>
// <param name="runAt">Where the interface should execute</param>
public override void PartCommunicationConnect(
    string interfaceName,
    WebPart connectedPart,
    string connectedInterfaceName,
    ConnectionRunAt runAt)
{
    // Keep track of whether the Web Part is connected.
    if (interfaceName == "MyCellProviderInterface_WPQ_")
    {
        _connected = true;
        _connectedWebPartTitle = SPEncode.HtmlEncode(connectedPart.Title);
    }
}

Show:
© 2014 Microsoft