Export (0) Print
Expand All

WebPart.PartCommunicationInit method

NOTE: This API is now obsolete.

Provides a connectable Web Part with a method for firing any of its initialization events, such as the CellProviderInit or CellConsumerInit event.

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

[ObsoleteAttribute("Use ConnectionProvider or ConnectionConsumer attribute to create ConnectionPoint instead.")]
public virtual void PartCommunicationInit()

The following code example shows an overridden PartCommunicationInit method that fires the CellProviderInit event. This code example is part of a larger example provided for the ICellProvider interface.

For an overview of the steps for creating a connectable Web Part, see Walkthrough: Creating a Connectable SharePoint Web Part.

// Step #9: Override the PartCommunicationInit() method
// PartCommunicationInit() is called by the Web Part infrastructure during the ASP.NET PreRender 
// event to allow the part to pass initialization information to the other connected parts.
// It is important to always pass initialization information as some parts
// may not behave properly if this initialization information is not received.
public override void PartCommunicationInit()
{
    // Check if connected
    if(_connected)
    {
        // If there is a listener, fire the CellProviderInit event.
        if (CellProviderInit != null)
        {
            // Create the CellProviderInitEventArgs structure for the CellProviderInit event.
            CellProviderInitEventArgs cellProviderInitArgs = new CellProviderInitEventArgs();

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

            // Fire the CellProviderInit event.
            CellProviderInit(this, cellProviderInitArgs);
        }
    }
}

Community Additions

Show:
© 2014 Microsoft