Поделиться через


Метод WebPart.PartCommunicationConnect

Примечание. Этот API устарел.

Используется для уведомления веб-часть подключена к другой веб-части.

Пространство имен:  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

    Задает имя интерфейса на этой веб-части подключаемого.

  • connectedInterfaceName
    Тип: System.String

    Указывает имя интерфейса, который подключен к в веб-части.

Замечания

Веб-части, который реализует интерфейс подключения следует переопределить метод PartCommunicationConnect . Этот метод вызывается инфраструктурой веб-части для уведомления веб-части, что он подключен во время события System.Web.UI.Control.PreRender Microsoft ASP.NET. Сведения о передается подключение веб-части, такие как интерфейс подключения через веб-части подключения и где часть будет работать под управлением, со стороны клиента или на сервере.

Если веб-часть, которая подключена к на другую страницу, connectedPart — пустая ссылка (Nothing в Visual Basic).

Примеры

В следующем примере кода показан метод переопределенный PartCommunicationConnect . Этот пример кода является частью большего примера для интерфейса ICellProvider .

Поскольку в этом примере используется класс Microsoft.SharePoint.Utilities.SPEncode , требуется директива using (Imports в Visual Basic) для пространства имен 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