WebPart.PartCommunicationConnect 方法

请注意:此 API 现在已过时。

用于通知 Web 部件它已连接到另一个 Web 部件。

命名空间:  Microsoft.SharePoint.WebPartPages
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
<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
    类型:System.String

    正在连接此 Web 部件上指定接口的名称。

  • connectedInterfaceName
    类型:System.String

    指定在其他 Web 部件连接到接口的名称。

备注

实现连接接口的 Web 部件应替代PartCommunicationConnect方法。通过 Web 部件基础结构,以通知 Web 部件连接在 Microsoft ASP.NET System.Web.UI.Control.PreRender事件期间调用此方法。相关信息传递给连接 (例如接口的 Web 部件通过连接、 Web 部件正在连接到,和其中部件将运行,客户端或服务器端。

如果正在连接到 Web 部件在另一页上, connectedPart是空引用(无 在 Visual Basic 中)。

示例

下面的代码示例演示重写的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 类

WebPart 成员

Microsoft.SharePoint.WebPartPages 命名空间