WebPart.GetInitEventArgs - Méthode

Remarque : cette API est désormais obsolète.

Renvoie l'objet InitEventArgs pour le nom de l'interface qui est passé.

Espace de noms :  Microsoft.SharePoint.WebPartPages
Assembly :  Microsoft.SharePoint (dans Microsoft.SharePoint.dll)

Syntaxe

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

Paramètres

Valeur renvoyée

Type : Microsoft.SharePoint.WebPartPages.Communication.InitEventArgs
Un objet InitEventArgs tel qu'un objet CellProviderInitEventArgs renvoyé par un composant WebPart qui implémente l'interface ICellProvider .

Remarques

La méthode GetInitEventArgs est uniquement requis pour les interfaces de l'espace de noms Microsoft.SharePoint.WebPartPages.Communication qui peuvent utiliser des convertisseurs, telles que les interfaces IRowProvider, ICellConsumer, IFilterConsumer, IParametersOutProvideret IParametersInConsumer . La méthode InitEventArgs est appelée par la connexion basée sur le Web de création d'interface utilisateur pour toutes les données initiales requises pour la création d'une connexion qui implique un transformateur. Il s'agit d'une méthode virtuelle sur la WebPart qui doit être remplacé par le développeur pour les interfaces qui utilisent des convertisseurs. Si elle n'est pas substituée, un message d'erreur s'affiche.

Exemples

L'exemple de code suivant illustre une méthode substituée GetInitEventArgs . Cet exemple de code fait partie d'un exemple plus complet fourni pour l'interface ICellConsumer .

Pour une vue d'ensemble des étapes de la création d'un composant WebPart connectable, voir 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);
    }
}

Voir aussi

Référence

WebPart classe

WebPart - Membres

Microsoft.SharePoint.WebPartPages - Espace de noms