Share via


WebPart.PartCommunicationConnect-Methode

HINWEIS: Diese API ist veraltet.

Verwendet, um ein Webpart zu benachrichtigen, dass es zu einem anderen Webpart verbunden wurde.

Namespace:  Microsoft.SharePoint.WebPartPages
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
<ObsoleteAttribute("Use ConnectionProvider or ConnectionConsumer attribute to create ConnectionPoint instead.")> _
Public Overridable Sub PartCommunicationConnect ( _
    interfaceName As String, _
    connectedPart As WebPart, _
    connectedInterfaceName As String, _
    runAt As ConnectionRunAt _
)
'Usage
Dim instance As WebPart
Dim interfaceName As String
Dim connectedPart As WebPart
Dim connectedInterfaceName As String
Dim runAt As ConnectionRunAt

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

Parameter

  • interfaceName
    Typ: System.String

    Gibt den Namen der Schnittstelle dieses Webparts, die verbunden wird.

  • connectedInterfaceName
    Typ: System.String

    Gibt den Namen der Schnittstelle, die angeschlossen ist auf dem anderen Webpart.

Hinweise

Ein Webpart, das eine Verbindungsschnittstelle implementiert sollte die PartCommunicationConnect -Methode außer Kraft setzen. Diese Methode wird aufgerufen, von der Webpartinfrastruktur, um das Webpart zu benachrichtigen, dass sie bei einem Microsoft ASP.NET System.Web.UI.Control.PreRender Ereignis verbunden ist. Relevante Informationen wird an das Herstellen einer Verbindung mit übergeben Webpart wie die-Schnittstelle, die es über verbunden ist und das Webpart wird mit verbunden ist, in dem das Webpart wird ausgeführt, clientseitige oder serverseitige.

Webparts, das angeschlossen ist ist auf einer anderen Seite, connectedPartein Nullverweis (Nothing in Visual Basic).

Beispiele

Das folgende Codebeispiel zeigt eine überschriebene PartCommunicationConnect -Methode. Dieses Codebeispiel ist Teil eines umfangreicheren Beispiels für die ICellProvider -Schnittstelle.

Da in diesem Beispiel wird die Microsoft.SharePoint.Utilities.SPEncode -Klasse verwendet, ist eine using -Direktive (Imports in Visual Basic) für den Microsoft.SharePoint.Utilities -Namespace erforderlich.

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

Public Overrides Sub PartCommunicationConnect( _
    interfaceName As String, _
    connectedPart As WebPart, _
    connectedInterfaceName As String, _
    runAt As ConnectionRunAt)

   ' Keep track of whether the Web Part is connected.
   If interfaceName = "MyCellProviderInterface_WPQ_" Then
      _connected = True
      _connectedWebPartTitle = SPEncode.HtmlEncode(connectedPart.Title)
    End If
End Sub
// 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);
    }
}

Siehe auch

Referenz

WebPart Klasse

WebPart-Member

Microsoft.SharePoint.WebPartPages-Namespace