共用方式為


WebPart.PartCommunicationConnect method

NOTE: This API is now obsolete.

用於通知網頁組件它已連接到另一個網頁組件。

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

Syntax

'宣告
<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 _
)
'用途
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
)

參數

  • interfaceName
    Type: System.String

    指定此網頁組件所連接的介面的名稱。

  • connectedInterfaceName
    Type: System.String

    指定所要連接的介面的名稱上其他網頁組件。

備註

網頁組件,實作的連線介面應該覆寫PartCommunicationConnect方法。依網頁組件基礎結構,以通知網頁組件連線 Microsoft ASP.NET System.Web.UI.Control.PreRender事件期間呼叫此方法。相關資訊傳遞至連接網頁組件,例如介面它透過連線、 網頁組件中所要連接,且其中之組件會執行,用戶端或伺服器端。

若要連接至網頁組件,在另一個頁面上connectedPart是a null reference (Nothing in Visual Basic)。

Examples

下列程式碼範例會顯示覆寫的PartCommunicationConnect方法。此程式碼範例會是範例的較大ICellProvider介面所提供的一部分。

本範例會使用Microsoft.SharePoint.Utilities.SPEncode類別,因為它需要using指示詞 (在 Visual Basic 中的Imports ) Microsoft.SharePoint.Utilities命名空間。

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);
    }
}

請參閱

參照

WebPart class

WebPart members

Microsoft.SharePoint.WebPartPages namespace