Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ParametersInReady Event
Collapse the table of content
Expand the table of content

IParametersInProvider.ParametersInReady Event

NOTE: This API is now obsolete.

Occurs when the parameter list is ready to be sent to the consumer Web Part. On the client computer, it can occur at any time; however, it is typically raised when a parameter is updated or selected. On the server, it must be raised in the PartCommunicationMain method.

Namespace:  Microsoft.SharePoint.WebPartPages.Communication
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

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

The event handler receives an argument of type Microsoft.SharePoint.WebPartPages.Communication.ParametersInReadyEventArgs containing data related to this event. ParametersInReadyEventArgs contains an array of strings in its ParameterValues property. Each string in the array is a value of a parameter. The number and order of parameters represented in this array must match those specified by the Microsoft.SharePoint.WebPartPages.Communication.ParametersInConsumerInitEventArgs argument in the ParametersInConsumerInit method.

A Web Part that implements the IParametersInProvider interface should always raise either the ParametersInReady event or the NoParametersIn event. Some Web Parts may not behave properly if they do not receive this information. Raise the ParametersInReady event to send the parameters. Raise the NoParametersIn event to indicate that there is no change in the parameters.

The following code example shows an overridden PartCommunicationMain method that fires the ParametersInReady event. This code example is part of a larger example provided for the IParametersInProvider interface.

// 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;
                }
            }
        }
    }
}


Show:
© 2015 Microsoft