Поделиться через


Событие IParametersInConsumer.ParametersInConsumerInit

Примечание. Этот API устарел.

Позволяет передавать информацию о параметрах, которые он ожидает Соединенные части веб-части потребителя.

Пространство имен:  Microsoft.SharePoint.WebPartPages.Communication
Сборка:  Microsoft.SharePoint (в Microsoft.SharePoint.dll)

Синтаксис

'Декларация
<ObsoleteAttribute("Use System.Web.UI.WebControls.WebParts.IWebPartParameters instead")> _
Event ParametersInConsumerInit As ParametersInConsumerInitEventHandler
'Применение
Dim instance As IParametersInConsumer
Dim handler As ParametersInConsumerInitEventHandler

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

Замечания

Обработчик события получает аргумент типа Microsoft.SharePoint.WebPartPages.Communication.ParametersInConsumerInitEventArgs , содержащий данные, относящиеся к этому событию. Объект ParametersInConsumerInitEventArgs содержит массив объектов Microsoft.SharePoint.WebPartPages.Communication.ParameterInProperty , с помощью свойства ParameterName, ParameterDisplayName, Requiredи Description.

Примеры

В следующем примере кода показан метод переопределения PartCommunicationInit , ParametersInConsumerInit событие. Данный пример кода является частью большего примера, приведенного для интерфейса IParametersInConsumer .

' Step #7: Override the PartCommunicationInit method.
' The PartCommunicationInit method is called by the Web Part 
' infrastructure during the ASP.NET PreRender 
' phase to allow the part to pass initialization information to the 
' other connected parts.
' It is important to always pass initialization information. Some 
' parts
' may not behave properly if this initialization information is not 
' received.
Public Overrides Sub PartCommunicationInit()
    ' Ensure all controls have been created.
    EnsureChildControls()

    ' Check if connected.
    If _connected Then
        'Need to create the args for the ParametersInConsumerInit event
        Dim parametersInConsumerInitEventArgs As New ParametersInConsumerInitEventArgs()

        'Set the ParameterInProperties
        parametersInConsumerInitEventArgs.ParameterInProperties = New ParameterInProperty(3) {}

        parametersInConsumerInitEventArgs.ParameterInProperties(0) = New ParameterInProperty()
        parametersInConsumerInitEventArgs.ParameterInProperties(0).Description = _fontFamilyParamDescription
        parametersInConsumerInitEventArgs.ParameterInProperties(0).ParameterDisplayName = _fontFamilyParamDisplayName
        parametersInConsumerInitEventArgs.ParameterInProperties(0).ParameterName = _fontFamilyParamName
        parametersInConsumerInitEventArgs.ParameterInProperties(0).Required = True

        parametersInConsumerInitEventArgs.ParameterInProperties(1) = New ParameterInProperty()
        parametersInConsumerInitEventArgs.ParameterInProperties(1).Description = _fontColorParamDescription
        parametersInConsumerInitEventArgs.ParameterInProperties(1).ParameterDisplayName = _fontColorParamDisplayName
        parametersInConsumerInitEventArgs.ParameterInProperties(1).ParameterName = _fontColorParamName
        parametersInConsumerInitEventArgs.ParameterInProperties(1).Required = False

        parametersInConsumerInitEventArgs.ParameterInProperties(2) = New ParameterInProperty()
        parametersInConsumerInitEventArgs.ParameterInProperties(2).Description = _fontWeightParamDescription
        parametersInConsumerInitEventArgs.ParameterInProperties(2).ParameterDisplayName = _fontWeightParamDisplayName
        parametersInConsumerInitEventArgs.ParameterInProperties(2).ParameterName = _fontWeightParamName
        parametersInConsumerInitEventArgs.ParameterInProperties(2).Required = True

        parametersInConsumerInitEventArgs.ParameterInProperties(3) = New ParameterInProperty()
        parametersInConsumerInitEventArgs.ParameterInProperties(3).Description = _fontSizeParamDescription
        parametersInConsumerInitEventArgs.ParameterInProperties(3).ParameterDisplayName = _fontSizeParamDisplayName
        parametersInConsumerInitEventArgs.ParameterInProperties(3).ParameterName = _fontSizeParamName
        parametersInConsumerInitEventArgs.ParameterInProperties(3).Required = False

        ' Fire the ParametersInConsumerInit event.
        RaiseEvent ParametersInConsumerInit(Me, parametersInConsumerInitEventArgs)
    End If
End Sub
// Step #7: Override the PartCommunicationInit method.
// The PartCommunicationInit method is called by the Web Part 
// infrastructure during the ASP.NET PreRender 
// phase to allow the part to pass initialization information to the 
// other connected parts.
// It is important to always pass initialization information. Some 
// parts
// may not behave properly if this initialization information is not 
// received.
public override void PartCommunicationInit()
{
    // Ensure all controls have been created.
    EnsureChildControls();

    // Check if connected.
    if(_connected)
    {
        // If there is a listener, fire the ParametersInConsumerInit 
        // event.
        if (ParametersInConsumerInit != null)
        {
            // Need to create the ParametersInConsumerInitEventArgs 
            // object for the ParametersInConsumerInit event.
            ParametersInConsumerInitEventArgs parametersInConsumerInitEventArgs = new ParametersInConsumerInitEventArgs();
            
            // Set the ParameterInProperties.
            parametersInConsumerInitEventArgs.ParameterInProperties = new ParameterInProperty[4];

            parametersInConsumerInitEventArgs.ParameterInProperties[0] = new ParameterInProperty();
            parametersInConsumerInitEventArgs.ParameterInProperties[0].Description = _fontFamilyParamDescription;
            parametersInConsumerInitEventArgs.ParameterInProperties[0].ParameterDisplayName = _fontFamilyParamDisplayName;
            parametersInConsumerInitEventArgs.ParameterInProperties[0].ParameterName = _fontFamilyParamName;
            parametersInConsumerInitEventArgs.ParameterInProperties[0].Required = true;

            parametersInConsumerInitEventArgs.ParameterInProperties[1] = new ParameterInProperty();
            parametersInConsumerInitEventArgs.ParameterInProperties[1].Description = _fontColorParamDescription;
            parametersInConsumerInitEventArgs.ParameterInProperties[1].ParameterDisplayName = _fontColorParamDisplayName;
            parametersInConsumerInitEventArgs.ParameterInProperties[1].ParameterName = _fontColorParamName;
            parametersInConsumerInitEventArgs.ParameterInProperties[1].Required = false;

            parametersInConsumerInitEventArgs.ParameterInProperties[2] = new ParameterInProperty();
            parametersInConsumerInitEventArgs.ParameterInProperties[2].Description = _fontWeightParamDescription;
            parametersInConsumerInitEventArgs.ParameterInProperties[2].ParameterDisplayName = _fontWeightParamDisplayName;
            parametersInConsumerInitEventArgs.ParameterInProperties[2].ParameterName = _fontWeightParamName;
            parametersInConsumerInitEventArgs.ParameterInProperties[2].Required = true;

            parametersInConsumerInitEventArgs.ParameterInProperties[3] = new ParameterInProperty();
            parametersInConsumerInitEventArgs.ParameterInProperties[3].Description = _fontSizeParamDescription;
            parametersInConsumerInitEventArgs.ParameterInProperties[3].ParameterDisplayName = _fontSizeParamDisplayName;
            parametersInConsumerInitEventArgs.ParameterInProperties[3].ParameterName = _fontSizeParamName;
            parametersInConsumerInitEventArgs.ParameterInProperties[3].Required = false;

            // Fire the ParametersInConsumerInit event.
            ParametersInConsumerInit(this, parametersInConsumerInitEventArgs);
        }
    }
}

См. также

Справочные материалы

IParametersInConsumer интерфейс

Элементы IParametersInConsumer

Пространство имен Microsoft.SharePoint.WebPartPages.Communication