WebPart.GetInitEventArgs 方法

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

返回InitEventArgs对象中传递的接口的名称。

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

语法

声明
<ObsoleteAttribute("Use ConnectionProvider or ConnectionConsumer attribute to create ConnectionPoint instead.")> _
Public Overridable Function GetInitEventArgs ( _
    InterfaceName As String _
) As InitEventArgs
用法
Dim instance As WebPart
Dim InterfaceName As String
Dim returnValue As InitEventArgs

returnValue = instance.GetInitEventArgs(InterfaceName)
[ObsoleteAttribute("Use ConnectionProvider or ConnectionConsumer attribute to create ConnectionPoint instead.")]
public virtual InitEventArgs GetInitEventArgs(
    string InterfaceName
)

参数

返回值

类型:Microsoft.SharePoint.WebPartPages.Communication.InitEventArgs
InitEventArgs 对象,如 Web 部件可实现ICellProvider接口返回CellProviderInitEventArgs对象。

备注

GetInitEventArgs方法才所需的Microsoft.SharePoint.WebPartPages.Communication命名空间,可以使用转换器,如IRowProviderICellConsumerIFilterConsumerIParametersOutProviderIParametersInConsumer接口的接口。创作用于创建一个连接,需要转换器所需的所有初始数据的用户界面的基于 Web 的连接调用InitEventArgs方法。它是必须由开发人员使用转换器的接口重写WebPart虚拟方法。如果没有重写,则显示一条错误消息。

示例

下面的代码示例演示重写的GetInitEventArgs方法。此代码示例是示例的一个更大提供的ICellConsumer接口的一部分。

创建可连接的 Web 部件的各个步骤的概述,请参阅Creating a Connectable Web Part。

' Step #11: Override the GetInitEventArgs() method.
' The GetInitEventArgs method is called by the Web Part infrastructure during the 
' ASP.NET PreRender event to gather the necessary information it needs to build
' the transformer dialog box. The transformer dialog box 
' is needed when connecting different interfaces such as IRowProvider
' to ICellConsumer. The transformer dialog box allows the user to map the fields between the 
' interfaces. The GetInitEventArgs method only needs to be implemented for interfaces that
' can participate in a transformer which are the following:
' ICellConsumer, IRowProvider, IFilterConsumer, IParametersOutProvider, IParametersInConsumer.
' interfacename is the name of interface on which the Web Part infrastructure is requesting 
' information.
' Returns an InitEventArgs object.

Public Overrides Function GetInitEventArgs(interfaceName As String) As InitEventArgs
   ' Check if this is my particular cell interface.
   If interfaceName = "MyCellConsumerInterface" Then
      ' Create the object that will return the initialization arguments.
      Dim cellConsumerInitArgs As New CellConsumerInitEventArgs()

      ' Set the FieldName and FieldDisplay name values.
      cellConsumerInitArgs.FieldName = _cellName
      cellConsumerInitArgs.FieldDisplayName = _cellDisplayName

      ' Return the CellConsumerInitEventArgs object.
      Return cellConsumerInitArgs
   Else
      Return Nothing
   End If
End Function
// Step #11: Override the GetInitEventArgs() method.
// The GetInitEventArgs method is called by the Web Part infrastructure during the ASP.NET PreRender event  
// to gather the necessary information it needs to build the transformer dialog box. The transformer dialog box
// is needed when connecting different interfaces such as IRowProvider
// to ICellConsumer. The transformer dialog box allows the user to map the fields between the 
// interfaces. The GetInitEventArgs method only needs to be implemented for interfaces that
// can participate in a transformer which are the following:
// ICellConsumer, IRowProvider, IFilterConsumer, IParametersOutProvider, IParametersInConsumer.
// <param name="interfacename">Name of interface on which the Web Part infrastructure is requesting information</param>
// <returns>An InitEventArgs object</returns>
public override InitEventArgs GetInitEventArgs(string interfaceName)
{
    // Check if this is my particular cell interface.
    if (interfaceName == "MyCellConsumerInterface")
    {
        // Create the object that will return the initialization arguments.
        CellConsumerInitEventArgs cellConsumerInitArgs = new CellConsumerInitEventArgs();

        // Set the FieldName and FieldDisplay name values.
        cellConsumerInitArgs.FieldName = _cellName;
        cellConsumerInitArgs.FieldDisplayName = _cellDisplayName;

        // Return the CellConsumerInitEventArgs object.
        return(cellConsumerInitArgs);
    }
    else
    {
        return(null);
    }
}

另请参阅

引用

WebPart 类

WebPart 成员

Microsoft.SharePoint.WebPartPages 命名空间