IParametersInProvider.ParametersInReady - Événement

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

Se produit lorsque la liste de paramètres est prête à être envoyée au composant WebPart consommateur. Sur l'ordinateur client, il peut se produire à tout moment. Toutefois, il est généralement déclenché lorsqu'un paramètre est mis à jour ou sélectionné. Sur le serveur, il doit être déclenché dans la méthode PartCommunicationMain .

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

Syntaxe

'Déclaration
<ObsoleteAttribute("Use System.Web.UI.WebControls.WebParts.IWebPartParameters instead")> _
Event ParametersInReady As ParametersInReadyEventHandler
'Utilisation
Dim instance As IParametersInProvider
Dim handler As ParametersInReadyEventHandler

AddHandler instance.ParametersInReady, handler
[ObsoleteAttribute("Use System.Web.UI.WebControls.WebParts.IWebPartParameters instead")]
event ParametersInReadyEventHandler ParametersInReady

Remarques

Le Gestionnaire d'événements reçoit un argument de type Microsoft.SharePoint.WebPartPages.Communication.ParametersInReadyEventArgs contenant des données liées à cet événement. ParametersInReadyEventArgs contient un tableau de chaînes dans sa propriété ParameterValues . Chaque chaîne du tableau est une valeur d'un paramètre. Le nombre et l'ordre des paramètres représentées dans ce tableau doivent correspondre à ceux spécifiés par l'argument de Microsoft.SharePoint.WebPartPages.Communication.ParametersInConsumerInitEventArgs dans la méthode ParametersInConsumerInit .

Un composant qui implémente l'interface IParametersInProvider doit toujours déclencher l'événement ParametersInReady ou l'événement NoParametersIn . Certains WebParts peut se comporter correctement si elles ne reçoivent pas ces informations. Déclenche l'événement ParametersInReady pour envoyer les paramètres. Déclenche l'événement NoParametersIn pour indiquer qu'il n'y a aucun changement dans les paramètres.

Exemples

L'exemple de code suivant montre une méthode substituée PartCommunicationMain qui déclenche l'événement ParametersInReady . Cet exemple de code fait partie d'un exemple plus développé fourni pour l'interface IParametersInProvider .

      ' Step #7: Implement the PartCommunicationMain() method.
      ' The PartCommunicationMain method is called by the Web Part 
      ' infrastructure on the client during the ASP.NET PreRender
      ' event to allow the part to pass its primary data to the other 
      ' connected parts.
      ' It is important to always fire either the ParametersInReady or 
      ' the NoParametersIn event. Some parts
      ' may not behave properly if they are left waiting for this 
      ' information.
      ' ParametersInReady should be fired to send the parameters.
      ' NoParametersIn should be fired to indicate that there is no 
      ' change in the parameters.
      Public Overrides Sub PartCommunicationMain()
            ' Ensure that all of the Web Part's controls are created.
            EnsureChildControls()

            'Check if connected
            If _connected Then
                ' Create the ParametersInReadyEventArgs object for the ParametersInReady event.
                Dim parametersInReadyEventArgs As New ParametersInReadyEventArgs()

                If _parametersReadyButtonClicked Then 'ParametersInReady Button was clicked

                    ' Set the parameter values to the text box values.
                    If Not (_fieldList Is Nothing) Then
                        parametersInReadyEventArgs.ParameterValues = New String(_fieldList.Length) {}

                        Dim index As Integer
                        For index = 0 To _fieldList.Length - 1
                            parametersInReadyEventArgs.ParameterValues(index) = _fontAttributeTextBox(index).Text
                        Next index

                        ' Fire the ParametersInReady event.
                        RaiseEvent ParametersInReady(Me, parametersInReadyEventArgs)
                        '_fieldList is null
                    Else
                        ' Fire the event.
                        RaiseEvent NoParametersIn(Me, New EventArgs())
                    End If
                    _parametersReadyButtonClicked = False
                ElseIf _noParametersInButtonClicked Then 'NoParametersIn Button was clicked                       
                    ' Fire the NoParametersIn event.
                    RaiseEvent NoParametersIn(Me, New EventArgs())
                    _noParametersInButtonClicked = False
                End If
            End If
        End Sub
// Step #7: Implement the PartCommunicationMain() method.
// The PartCommunicationMain method is called by the Web Part 
// infrastructure on the client during the ASP.NET PreRender
// phase to allow the part to pass its primary data to the other 
// connected parts.
// It is important to always fire either the ParametersInReady or the 
// NoParametersIn event. Some parts
// may not behave properly if they are left waiting for this 
// information.
// ParametersInReady should be fired to send the parameters.
// NoParametersIn should be fired to indicate that there is no change 
// in the parameters.
        
public override void PartCommunicationMain()
        {
    // Ensure that all of the Web Part's controls are created.
            EnsureChildControls();

    // Check if connected.
            if(_connected)
    {
                // If there is a listener, fire the ParametersInReady event.
        if(ParametersInReady != null)
        {
            // Create the ParametersInReadyEventArgs object for the 
            // ParametersInReady event.
            ParametersInReadyEventArgs parametersInReadyEventArgs = new ParametersInReadyEventArgs();

            // If the ParametersInReady button was clicked.
            if(_parametersReadyButtonClicked)
            {
                // If there is a listener, fire the ParametersInReady 
                // event.
                if(ParametersInReady != null)
                {
                    // Set the parameter values to the text box values.
                    if (_fieldList != null)
                        parametersInReadyEventArgs.ParameterValues = new string[_fieldList.Length];

                    for (int index = 0; index < _fieldList.Length; index++)
                    {
                        parametersInReadyEventArgs.ParameterValues[index] = _fontAttributeTextBox[index].Text;
                    }

                    // Fire the ParametersInReady event.
                    ParametersInReady(this, parametersInReadyEventArgs);

                    _parametersReadyButtonClicked = false;
                }
            }

            // If the NoParametersIn button was clicked.
            else if(_noParametersInButtonClicked)
            {
                // If there is a listener, fire the NoParametersIn 
                // event.
                if(NoParametersIn != null)
                {
                    // Fire the event.
                    NoParametersIn(this, new EventArgs());

                    _noParametersInButtonClicked = false;
                }
            }
            // The user didn't click any button.
            else 
            {
                // If there is a listener, fire the NoParametersIn 
                // event.
                if(NoParametersIn != null)
                {
                    // Fire the event
                    NoParametersIn(this, new EventArgs());

                    _noParametersInButtonClicked = false;
                }
            }
        }
    }
}

Voir aussi

Référence

IParametersInProvider interface

IParametersInProvider - Membres

Microsoft.SharePoint.WebPartPages.Communication - Espace de noms