Share via


WebPart.GetInitEventArgs Method

NOTE: This API is now obsolete.

Returns the InitEventArgs object for the name of the interface that is passed in.

Namespace:  Microsoft.SharePoint.WebPartPages
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

Syntax

'Declaration
<ObsoleteAttribute("Use ConnectionProvider or ConnectionConsumer attribute to create ConnectionPoint instead.")> _
Public Overridable Function GetInitEventArgs ( _
    InterfaceName As String _
) As InitEventArgs
'Usage
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
)

Parameters

Return Value

Type: Microsoft.SharePoint.WebPartPages.Communication.InitEventArgs
An InitEventArgs object such as a CellProviderInitEventArgs object returned by a Web Part that implements the ICellProvider interface.

Remarks

The GetInitEventArgs method is only required for the interfaces of the Microsoft.SharePoint.WebPartPages.Communication namespace that can use transformers, such as the IRowProvider, ICellConsumer, IFilterConsumer, IParametersOutProvider, and IParametersInConsumer interfaces. The InitEventArgs method is called by the Web-based connection authoring user interface for all the initial data required for creating a connection that involves a transformer. It is a virtual method on the WebPart that must be overridden by the developer for the interfaces that use transformers. If it is not overridden, an error message is displayed.

Examples

The following code example shows an overridden GetInitEventArgs method. This code example is part of a larger example provided for the ICellConsumer interface.

For an overview of the steps of creating a connectable Web Part, see 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);
    }
}

See Also

Reference

WebPart Class

WebPart Members

Microsoft.SharePoint.WebPartPages Namespace