6 Replies Latest reply on Dec 11, 2009 3:00 PM by spilon

    Client Side and IParametersOutProvider

    Jay5962

      Hi GuysI'm reffering to a blog http://vcampus.osisoft.com/blogs/piwp/archive/2008/12/05/comments-on-web-part-connections.aspx saying it’s very possible to write an IParametersOutProvider web part making use of both client and server side connection. In part the server connection works great, however if we flip the code over to use ConnectionRunAt.ServerAndClient and implement all code as suggested in http://msdn.microsoft.com/en-us/library/ms469765.aspx, the RTtrend doesn't recognize any input parameters. Can someone please look at my web part code or even better give me a client/server side hello world webpart using IParametersOutProvider :)  The code is as close to original as possible as I only want to prove its possible a client/server webpart can send parameters to RTtrend, maybe I'm missing something really easy???????????//

       

       

       

      // Common .NET required namespaces

       

      using System;

       

      using System.ComponentModel;

       

      using System.Web.UI;

       

      using System.Runtime.InteropServices;

       

      // WebPart required namespaces

       

      using Microsoft.SharePoint.WebPartPages;

       

      using System.Xml.Serialization;

       

      using System.Web.UI.WebControls;

       

       

       

      // Required for ArrayLists

       

      using System.Collections;

       

       

       

      // Code Access Security namespaces

       

      using System.Security;

       

      using Microsoft.SharePoint.Utilities;

       

       

       

      //Step #1: Reference the Communication namespace.

       

      using Microsoft.SharePoint.WebPartPages.Communication;

       

       

       

       

       

      namespace ConnectionCodeSamples

       

      {

       

          // Step #2: Inherit from the WebPart base class and implement the

       

          // IParametersOutProvider interface.

       

       

       

          [Guid("aafe696f-b9c6-4204-94c4-d4feb5e6a5be")]

       

          public class ClientSideParametersOutProvider : WebPart, IParametersOutProvider

       

          {

       

       

       

              // Step #3: Declare the IParametersOutProvider events.

       

              // Because this class implements the IParametersOutProvider

       

              // interface, it must declare the interface members

       

              // ParametersOutProviderInit, ParametersOutReady, and

       

              // NoParametersOut.

       

       

       

              public event ParametersOutProviderInitEventHandler ParametersOutProviderInit;

       

              public event ParametersOutReadyEventHandler ParametersOutReady;

       

              public event NoParametersOutEventHandler NoParametersOut;

       

       

       

              // Declare variables for keeping track of connection state.

       

              private bool _connected = false;

       

              private string _connectedWebPartTitle = string.Empty;

       

              private string _registrationErrorMsg = "An error has occurred trying to register your connection interfaces.";

       

              private bool _registrationErrorOccurred = false;

       

              private string _notConnectedMsg = "NOT CONNECTED. To use this Web Part connect it to a ParametersOut or ParametersIn Consumer Web Part.";

       

       

       

              // Declare variables for Web Part user interface.

       

              private string _connectedWebPartLabel = "Connected to Web Part";

       

              DropDownList _fontFamilyListBox;

       

              DropDownList _fontColorListBox;

       

              DropDownList _fontWeightListBox;

       

              DropDownList _fontSizeListBox;

       

              ArrayList _fontFamilyArrayList;

       

              ArrayList _fontColorArrayList;

       

              ArrayList _fontWeightArrayList;

       

              ArrayList _fontSizeArrayList;

       

              private Button _parametersReadyButton;

       

              private bool _parametersReadyButtonClicked = false;

       

              private Button _noParametersOutButton;

       

              private bool _noParametersOutButtonClicked = false;

       

       

       

              // Declare variables for Parameter attributes.

       

              string _fontFamilyParamDescription = "Font Family";

       

              string _fontFamilyParamDisplayName = "Font";

       

              string _fontFamilyParamName = "FontFamily";

       

              string _fontColorParamDescription = "Font Color";

       

              string _fontColorParamDisplayName = "Color";

       

              string _fontColorParamName = "FontColor";

       

              string _fontWeightParamDescription = "Font Weight";

       

              string _fontWeightParamDisplayName = "Weight";

       

              string _fontWeightParamName = "FontWeight";

       

              string _fontSizeParamDescription = "Font Size";

       

              string _fontSizeParamDisplayName = "Size";

       

              string _fontSizeParamName = "FontSize";

       

       

       

              // Constructor

       

              public ClientSideParametersOutProvider()

       

              {

       

                  // Create Array List objects.

       

                  _fontFamilyArrayList = new ArrayList();

       

                  _fontColorArrayList = new ArrayList();

       

                  _fontWeightArrayList = new ArrayList();

       

                  _fontSizeArrayList = new ArrayList();

       

       

       

                  // Add items to _fontFamilyArrayList.

       

                  _fontFamilyArrayList.Add("Times");

       

                  _fontFamilyArrayList.Add("Arial");

       

                  _fontFamilyArrayList.Add("Verdana");

       

                  _fontFamilyArrayList.Add("Courier");

       

       

       

                  // Add items to _fontColorArrayList.

       

                  _fontColorArrayList.Add("Black");

       

                  _fontColorArrayList.Add("Red");

       

                  _fontColorArrayList.Add("Green");

       

                  _fontColorArrayList.Add("Yellow");

       

                  _fontColorArrayList.Add("Blue");

       

       

       

                  // Add items to _fontWeightArrayList.

       

                  _fontWeightArrayList.Add("Normal");

       

                  _fontWeightArrayList.Add("Bold");

       

       

       

                  // Add items to _fontSizeArrayList.

       

                  _fontSizeArrayList.Add("10pt");

       

                  _fontSizeArrayList.Add("12pt");

       

                  _fontSizeArrayList.Add("14pt");

       

                  _fontSizeArrayList.Add("20pt");

       

       

       

              }

       

       

       

              // Step #4: Override the EnsureInterfaces method and call

       

              // RegisterInterface method.

       

              // The EnsureInterfaces method is called by the Web Part

       

              // infrastructure during the ASP.NET PreRender event

       

              // and allows the part to register all of its connection

       

              // interfaces.

       

       

       

              public override void EnsureInterfaces()

       

              {

       

                  // If your Web Part is installed in the bin directory and

       

                  // the Code Access Security (CAS) setting doesn't

       

                  // allow Web Part Connections, an exception will be thrown.

       

                  // To allow your Web Part to behave

       

                  // well and continue working, a try/catch block should be

       

                  // used when attempting to register interfaces.

       

                  // Web Part Connections will only work if the level

       

                  // attribute of the <trust> tag in the

       

                  // web.config file is set to WSS_Minimal, WSS_Medium, or

       

                  // Full. By default a new SharePoint site

       

                  // is installed with the trust level set to WSS_Minimal.

       

                  try

       

                  {

       

                      // Register the IParametersOutProvider Interface

       

                      // <param name="interfaceName">Friendly name of the

       

                      // interface that is being implemented.</param>

       

                      // <param name="interfaceType">Specifies which

       

                      // <interface is being implemented.</param>

       

                      // <param name="maxConnections">Defines how many times

       

                      // <this interface can be connected.</param>

       

                      // <param name="runAtOptions">Determines where the

       

                      // <interface can run.</param>

       

                      // <param name="interfaceObject">Reference to the

       

                      // <object that is implementing this interface.</param>

       

                      // <param name="interfaceClientReference">Name used to

       

                      // <reference the interface on the client.

       

                      // This is a server side example so the value is set to

       

                      // <empty string.</param>

       

                      // <param name="menuLabel">Label for the interface

       

                      // <that appears in the UI</param>

       

                      // <param name="description">Description of the

       

                      // <interface that appears in the UI</param>

       

                      // <param name="allowCrossPageConnection">Specifies if

       

                      // <the interface can connect to a Web Part

       

                      // on a different page. This is an optional parameter

       

                      // <with a default of false. Note that only some

       

                      // server side interfaces are allowed to connect across

       

                      // <pages by the Web Part infrastructure.

       

                      // The IParametersOutProvider interface is allowed to

       

                      // <connect across pages.</param>

       

                      RegisterInterface("MyParametersOutProviderInterface_WPQ_",        //InterfaceName   

       

                          InterfaceTypes.IParametersOutProvider,                    //InterfaceType

       

                          WebPart.UnlimitedConnections,                            //MaxConnections

       

                          ConnectionRunAt.ServerAndClient,                                    //RunAtOptions

       

                          this,                                                    //InterfaceObject

       

                          " _ParametersOutProviderInterface_WPQ_ ",                                                        //InterfaceClientReference

       

                          "Provide Parameters To",                                //MenuLabel

       

                          "Provides a font parameters to a consumer Web Part.",    //Description

       

                          true);                                                    //allowCrossPageConnection

       

                  }

       

                  catch (SecurityException se)

       

                  {

       

                      _registrationErrorOccurred = true;

       

                  }

       

              }

       

       

       

       

       

              // Step #5: Override the CanRunAt method.

       

              // The CanRunAt method is called by the Web Part infrastructure

       

              // during the ASP.NET PreRender event

       

              // to determine where the Web Part can run based on its current

       

              // configuration.

       

       

       

              public override ConnectionRunAt CanRunAt()

       

              {

       

                  // This Web Part can run on the server.

       

                  return ConnectionRunAt.ServerAndClient;

       

              }

       

       

       

              // Step #6: Override the PartCommunicationConnect method.

       

              // The PartCommunicationConnect method is called by the Web

       

              // Part infrastructure to notify the Web Part that it

       

              // is connected during the ASP.NET PreRender event. Relevant

       

              // information is passed to the part such as

       

              // the interface it is connected over, the Web Part it is being

       

              // connected to, and where the part will be running,

       

              // either client or server side.

       

              // <param name="interfaceName">Friendly name of the interface

       

              // that is being connected</param>

       

              // <param name="connectedPart">Reference to the other Web Part

       

              // that is being connected to</param>

       

              // <param name="connectedInterfaceName">Friendly name of the

       

              // interface on the other Web Part</param>

       

              // <param name="runAt">Where the interface should

       

              // execute</param>

       

              public override void PartCommunicationConnect(

       

                  string interfaceName,

       

                  WebPart connectedPart,

       

                  string connectedInterfaceName,

       

                  ConnectionRunAt runAt)

       

              {

       

                  // Keep track of connection state.

       

                  if (interfaceName == "MyParametersOutProviderInterface_WPQ_")

       

                  {

       

                      _connected = true;

       

                      _connectedWebPartTitle = SPEncode.HtmlEncode(connectedPart.Title);

       

                  }

       

              }

       

       

       

              // 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 that all of the Web Part's controls are created.

       

                  EnsureChildControls();

       

       

       

                  // Check if connected.

       

                  if (_connected)

       

                  {

       

                      // If there is a listener, fire the

       

                      // ParametersOutProviderInit event.

       

                      if (ParametersOutProviderInit != null)

       

                      {

       

                          // Need to create the

       

                          // ParametersOutProviderInitEventArgs object for

       

                          // the ParametersOutProviderInit event.

       

                          ParametersOutProviderInitEventArgs parametersOutProviderInitInitEventArgs = new ParametersOutProviderInitEventArgs();

       

       

       

                          // Set the ParameterOutProperties.

       

                          parametersOutProviderInitInitEventArgs.ParameterOutProperties = new ParameterOutProperty[4];

       

       

       

                          // There are 4 parameters types that will be

       

                          // passed: Font Family, Color, Weight, and Size.

       

                          parametersOutProviderInitInitEventArgs.ParameterOutProperties[0] = new ParameterOutProperty();

       

                          parametersOutProviderInitInitEventArgs.ParameterOutProperties[0].Description = _fontFamilyParamDescription;

       

                          parametersOutProviderInitInitEventArgs.ParameterOutProperties[0].ParameterDisplayName = _fontFamilyParamDisplayName;

       

                          parametersOutProviderInitInitEventArgs.ParameterOutProperties[0].ParameterName = _fontFamilyParamName;

       

       

       

                          parametersOutProviderInitInitEventArgs.ParameterOutProperties[1] = new ParameterOutProperty();

       

                          parametersOutProviderInitInitEventArgs.ParameterOutProperties[1].Description = _fontColorParamDescription;

       

                          parametersOutProviderInitInitEventArgs.ParameterOutProperties[1].ParameterDisplayName = _fontColorParamDisplayName;

       

                          parametersOutProviderInitInitEventArgs.ParameterOutProperties[1].ParameterName = _fontColorParamName;

       

       

       

                          parametersOutProviderInitInitEventArgs.ParameterOutProperties[2] = new ParameterOutProperty();

       

                          parametersOutProviderInitInitEventArgs.ParameterOutProperties[2].Description = _fontWeightParamDescription;

       

                          parametersOutProviderInitInitEventArgs.ParameterOutProperties[2].ParameterDisplayName = _fontWeightParamDisplayName;

       

                          parametersOutProviderInitInitEventArgs.ParameterOutProperties[2].ParameterName = _fontWeightParamName;

       

       

       

                          parametersOutProviderInitInitEventArgs.ParameterOutProperties[3] = new ParameterOutProperty();

       

                          parametersOutProviderInitInitEventArgs.ParameterOutProperties[3].Description = _fontSizeParamDescription;

       

                          parametersOutProviderInitInitEventArgs.ParameterOutProperties[3].ParameterDisplayName = _fontSizeParamDisplayName;

       

                          parametersOutProviderInitInitEventArgs.ParameterOutProperties[3].ParameterName = _fontSizeParamName;

       

       

       

                          // Fire the ParametersOutProviderInit event.

       

                          ParametersOutProviderInit(this, parametersOutProviderInitInitEventArgs);

       

                      }

       

                  }

       

              }

       

       

       

              // Step #8: Override 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 ParametersOutReady

       

              // or the NoParametersOut event. Some parts

       

              // may not behave properly if they are left waiting for this

       

              // information.

       

              // ParametersOutReady should be fired to send the parameters.

       

              // NoParametersOut 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 ParametersOutReady event.

       

                      if (ParametersOutReady != null)

       

                      {

       

                          // Need to create the ParametersOutReadyEventArgs

       

                          // object for the ParametersOutReady event.

       

                          ParametersOutReadyEventArgs parametersOutReadyEventArgs = new ParametersOutReadyEventArgs();

       

       

       

                          if (_parametersReadyButtonClicked) //ParametersOutReady Button was clicked

       

                          {

       

                              // If there is a listener, fire the

       

                              // ParametersOutReady event.

       

                              if (ParametersOutReady != null)

       

                              {

       

                                  // Set the values to the values of the text

       

                                  // boxes.

       

                                  parametersOutReadyEventArgs.ParameterValues = new string[4];

       

                                  parametersOutReadyEventArgs.ParameterValues[0] = _fontFamilyListBox.SelectedItem.Value;

       

                                  parametersOutReadyEventArgs.ParameterValues[1] = _fontColorListBox.SelectedItem.Value;

       

                                  parametersOutReadyEventArgs.ParameterValues[2] = _fontWeightListBox.SelectedItem.Value;

       

                                  parametersOutReadyEventArgs.ParameterValues[3] = _fontSizeListBox.SelectedItem.Value;

       

       

       

                                  // Fire the ParametersOutReady event.

       

                                  ParametersOutReady(this, parametersOutReadyEventArgs);

       

       

       

                                  _parametersReadyButtonClicked = false;

       

                              }

       

                          }

       

                          //The NoParametersOut button was clicked.

       

                          else if (_noParametersOutButtonClicked)

       

                          {

       

                              // If there is a listener, fire the

       

                              // NoParametersOut event.

       

                              if (NoParametersOut != null)

       

                              {

       

                                  // Fire the event.

       

                                  NoParametersOut(this, new EventArgs());

       

       

       

                                  _noParametersOutButtonClicked = false;

       

                              }

       

                          }

       

                          // The user didn't click any button.

       

                          else

       

                          {

       

                              // If there is a listener, fire the

       

                              // NoParametersOut event.

       

                              if (NoParametersOut != null)

       

                              {

       

                                  // Fire the event.

       

                                  NoParametersOut(this, new EventArgs());

       

       

       

                                  _noParametersOutButtonClicked = false;

       

                              }

       

                          }

       

                      }

       

                  }

       

              }

       

       

       

              // Step #9: Override the GetInitEventArgs method.

       

              // GetInitEventArgs() 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. The transformer dialog

       

              // is needed when connecting different interfaces such as

       

              // IRowProvider to ICellConsumer. The transformer dialog 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 ParametersOut interface.

       

                  if (interfaceName == "MyParametersOutProviderInterface_WPQ_")

       

                  {

       

                      // Ensure that child controls have been created

       

                      EnsureChildControls();

       

       

       

                      // Need to create the

       

                      // ParametersOutProviderInitEventArgs object for the

       

                      // ParametersOutProviderInit event.

       

                      ParametersOutProviderInitEventArgs parametersOutProviderInitInitEventArgs = new ParametersOutProviderInitEventArgs();

       

       

       

                      // Set the ParameterOutProperties.

       

                      parametersOutProviderInitInitEventArgs.ParameterOutProperties = new ParameterOutProperty[4];

       

       

       

                      //There are 4 parameters types that will be passed:

       

                      // Font Family, Color, Weight, and Size

       

                      parametersOutProviderInitInitEventArgs.ParameterOutProperties[0] = new ParameterOutProperty();

       

                      parametersOutProviderInitInitEventArgs.ParameterOutProperties[0].Description = _fontFamilyParamDescription;

       

                      parametersOutProviderInitInitEventArgs.ParameterOutProperties[0].ParameterDisplayName = _fontFamilyParamDisplayName;

       

                      parametersOutProviderInitInitEventArgs.ParameterOutProperties[0].ParameterName = _fontFamilyParamName;

       

       

       

                      parametersOutProviderInitInitEventArgs.ParameterOutProperties[1] = new ParameterOutProperty();

       

                      parametersOutProviderInitInitEventArgs.ParameterOutProperties[1].Description = _fontColorParamDescription;

       

                      parametersOutProviderInitInitEventArgs.ParameterOutProperties[1].ParameterDisplayName = _fontColorParamDisplayName;

       

                      parametersOutProviderInitInitEventArgs.ParameterOutProperties[1].ParameterName = _fontColorParamName;

       

       

       

                      parametersOutProviderInitInitEventArgs.ParameterOutProperties[2] = new ParameterOutProperty();

       

                      parametersOutProviderInitInitEventArgs.ParameterOutProperties[2].Description = _fontWeightParamDescription;

       

                      parametersOutProviderInitInitEventArgs.ParameterOutProperties[2].ParameterDisplayName = _fontWeightParamDisplayName;

       

                      parametersOutProviderInitInitEventArgs.ParameterOutProperties[2].ParameterName = _fontWeightParamName;

       

       

       

                      parametersOutProviderInitInitEventArgs.ParameterOutProperties[3] = new ParameterOutProperty();

       

                      parametersOutProviderInitInitEventArgs.ParameterOutProperties[3].Description = _fontSizeParamDescription;

       

                      parametersOutProviderInitInitEventArgs.ParameterOutProperties[3].ParameterDisplayName = _fontSizeParamDisplayName;

       

                      parametersOutProviderInitInitEventArgs.ParameterOutProperties[3].ParameterName = _fontSizeParamName;

       

       

       

                      // Return the parametersOutProviderInitInitEventArgs

       

                      // object.

       

                      return (parametersOutProviderInitInitEventArgs);

       

                  }

       

                  else

       

                  {

       

                      return (null);

       

                  }

       

              }

       

       

       

              protected override void RenderWebPart(HtmlTextWriter output)

       

              {

       

                  // Check for connection interface registration error.

       

                  if (_registrationErrorOccurred)

       

                  {

       

                      output.Write(_registrationErrorMsg);

       

                      return;

       

                  }

       

       

       

                  // Ensure that all of the Web Part's controls are created.

       

                  EnsureChildControls();

       

       

       

                  // Check if connected.

       

                  if (_connected)

       

                  {

       

                      // Render List Box table.

       

                      output.RenderBeginTag(HtmlTextWriterTag.Table); //Begin Table

       

       

       

                      // Font Family Row.

       

                      output.RenderBeginTag(HtmlTextWriterTag.Tr);    //Begin TR

       

                      output.RenderBeginTag(HtmlTextWriterTag.Td);    //Begin TD

       

                      output.RenderBeginTag(HtmlTextWriterTag.B);        //Begin B

       

                      output.Write(_fontFamilyParamDisplayName + ": ");    //Render List Box Label

       

                      output.RenderEndTag();                            //End </B>

       

                      output.RenderEndTag();                            //End </TD>

       

                      output.RenderBeginTag(HtmlTextWriterTag.Td);    //Begin TD

       

                      _fontFamilyListBox.RenderControl(output);        //Render list box

       

                      output.RenderEndTag();                            //End </TD>

       

                      output.RenderEndTag();                            //End </TR>

       

       

       

                      // Font Color Row.

       

                      output.RenderBeginTag(HtmlTextWriterTag.Tr);    //Begin TR

       

                      output.RenderBeginTag(HtmlTextWriterTag.Td);    //Begin TD

       

                      output.RenderBeginTag(HtmlTextWriterTag.B);        //Begin B

       

                      output.Write(_fontColorParamDisplayName + ": ");    //Render List Box Label

       

                      output.RenderEndTag();                            //End </B>

       

                      output.RenderEndTag();                            //End </TD>

       

                      output.RenderBeginTag(HtmlTextWriterTag.Td);    //Begin TD

       

                      _fontColorListBox.RenderControl(output);        //Render list box

       

                      output.RenderEndTag();                            //End </TD>

       

                      output.RenderEndTag();                            //End </TR>

       

       

       

                      // Font Weight Row.

       

                      output.RenderBeginTag(HtmlTextWriterTag.Tr);    //Begin TR

       

                      output.RenderBeginTag(HtmlTextWriterTag.Td);    //Begin TD

       

                      output.RenderBeginTag(HtmlTextWriterTag.B);        //Begin B

       

                      output.Write(_fontWeightParamDisplayName + ": ");    //Render List Box Label

       

                      output.RenderEndTag();                            //End </B>

       

                      output.RenderEndTag();                            //End </TD>

       

                      output.RenderBeginTag(HtmlTextWriterTag.Td);    //Begin TD

       

                      _fontWeightListBox.RenderControl(output);        //Render list box

       

                      output.RenderEndTag();                            //End </TD>

       

                      output.RenderEndTag();                            //End </TR>

       

       

       

                      // Font Size Row.

       

                      output.RenderBeginTag(HtmlTextWriterTag.Tr);    //Begin TR

       

                      output.RenderBeginTag(HtmlTextWriterTag.Td);    //Begin TD

       

                      output.RenderBeginTag(HtmlTextWriterTag.B);        //Begin B

       

                      output.Write(_fontSizeParamDisplayName + ": ");    //Render List Box Label

       

                      output.RenderEndTag();                            //End </B>

       

                      output.RenderEndTag();                            //End </TD>

       

                      output.RenderBeginTag(HtmlTextWriterTag.Td);    //Begin TD

       

                      _fontSizeListBox.RenderControl(output);        //Render list box

       

                      output.RenderEndTag();                            //End </TD>

       

                      output.RenderEndTag();                            //End </TR>

       

       

       

                      output.RenderEndTag();                            //End <Table>

       

       

       

       

       

                      // Render buttons.

       

                      _parametersReadyButton.RenderControl(output);

       

                      _noParametersOutButton.RenderControl(output);

       

       

       

                      // Line break.

       

                      output.RenderBeginTag(HtmlTextWriterTag.Br);

       

                      output.RenderEndTag();

       

       

       

                      // Render connected Web Part title.

       

                      output.Write(_connectedWebPartLabel + ": ");

       

                      output.RenderBeginTag(HtmlTextWriterTag.I);

       

                      output.Write(_connectedWebPartTitle);

       

                      output.RenderEndTag();

       

       

       

                  }

       

                  else

       

                  {

       

                      // The Web Part isn't connected.

       

                      output.Write(_notConnectedMsg);

       

                  }

       

       

       

              }

       

       

       

              // Create Web Part user interface controls.

       

              protected override void CreateChildControls()

       

              {

       

                  // Create List Boxes.

       

                  _fontFamilyListBox = new DropDownList();

       

                  _fontColorListBox = new DropDownList();

       

                  _fontWeightListBox = new DropDownList();

       

                  _fontSizeListBox = new DropDownList();

       

       

       

                  // Set List Box IDs.

       

                  _fontFamilyListBox.ID = "FontFamilyListBox";

       

                  _fontColorListBox.ID = "FontColorListBox";

       

                  _fontWeightListBox.ID = "FontWeightListBox";

       

                  _fontSizeListBox.ID = "FontSizeListBox";

       

       

       

                  // Set List Box Values.

       

                  _fontFamilyListBox.DataSource = _fontFamilyArrayList;

       

                  _fontColorListBox.DataSource = _fontColorArrayList;

       

                  _fontWeightListBox.DataSource = _fontWeightArrayList;

       

                  _fontSizeListBox.DataSource = _fontSizeArrayList;

       

       

       

                  // Databind the List Boxes.

       

                  _fontFamilyListBox.DataBind();

       

                  _fontColorListBox.DataBind();

       

                  _fontWeightListBox.DataBind();

       

                  _fontSizeListBox.DataBind();

       

       

       

                  // Add List Boxes to Controls Collection.

       

                  Controls.Add(_fontFamilyListBox);

       

                  Controls.Add(_fontColorListBox);

       

                  Controls.Add(_fontWeightListBox);

       

                  Controls.Add(_fontSizeListBox);

       

       

       

                  // Create the ParametersOutReady button.

       

                  _parametersReadyButton = new Button();

       

                  _parametersReadyButton.ID = "ParametersOutReadyButton";

       

                  _parametersReadyButton.Text = "Fire ParametersOutReady";

       

                  Controls.Add(_parametersReadyButton);

       

       

       

                  // Create the NoParametersOut button.

       

                  _noParametersOutButton = new Button();

       

                  _noParametersOutButton.ID = "NoParametersOutButton";

       

                  _noParametersOutButton.Text = "Fire NoParametersOut";

       

                  Controls.Add(_noParametersOutButton);

       

       

       

       

       

                  // Hook up button clicks.

       

                  _parametersReadyButtonClicked = false; // Initialize to false -- user hasn't clicked yet

       

                  _parametersReadyButton.Click += new EventHandler(ParametersOutReadyButtonClicked); // listen for Button's click event

       

       

       

                  _noParametersOutButtonClicked = false; // Initialize to false -- user hasn't clicked yet

       

                  _noParametersOutButton.Click += new EventHandler(NoParametersOutButtonClicked); // listen for Button's click event

       

              }

       

       

       

              // The ParametersOutReadyButton OnClick event handler.

       

              // <param name="sender">The Button object</param>

       

              // <param name="e">The Event Arguments</param>

       

              private void ParametersOutReadyButtonClicked(object sender, EventArgs e)

       

              {

       

                  _parametersReadyButtonClicked = true; //user clicked button, set to true

       

              }

       

       

       

       

       

              // The NoParametersOutButton OnClick event handler.

       

              // <param name="sender">The Button object</param>

       

              // <param name="e">The Event Arguments</param>

       

              private void NoParametersOutButtonClicked(object sender, EventArgs e)

       

              {

       

                  _noParametersOutButtonClicked = true; //user clicked button, set to true

       

              }

       

          }

       

      }

       

       

        • Re: Client Side and IParametersOutProvider
          cescamilla

          I'll try this code out in Visual Studio and get back to you :)

          • Re: Client Side and IParametersOutProvider
            cescamilla

            Your code does run, it seems you are asking for supporting both, client and server side connections, and that you are only returning an array of strings.

             

            Now for the good part I have been able to replicate your problem, but the downside is I have not been able to find the solution yet.

             

            Rest asure that we are working on this,

             

             

             

            Please bear with us.

             

             

             

             

              • Re: Client Side and IParametersOutProvider
                Asle Frantzen

                Not sure if this applies here, but when I'm doing this I implement this for server-side connections:

                public class ParametersOutProviderImp :IParametersOutProvider
                { ... }

                and then I add this javascript code in the start of the RenderWebPart method to handle client-side connections:

                var _ParametersOutProviderInitEventArgs_WPQ_;
                var _ParametersOutReadyEventArgs_WPQ_;
                var aliasTagList_WPQ_, aliasList_WPQ_, nodeId_WPQ_;

                var ParametersOutProviderInterface_WPQ_ = new Provider_WPQ_();
                function Provider_WPQ_()
                {
                 this.PartCommunicationInit = myInit;
                 this.PartCommunicationMain = myMain;
                 this.Title = "<WebPartName>";

                 function myInit()
                 {
                  parametersOutProviderInitEventArgs = new Object();
                           
                  // Set the ParameterOutProperties.
                  parametersOutProviderInitEventArgs.ParameterOutProperties = new Object();
                  parametersOutProviderInitEventArgs.ParameterOutProperties[0] = new Object();
                  parametersOutProviderInitEventArgs.ParameterOutProperties[0].Description = "AliasTagList";
                  parametersOutProviderInitEventArgs.ParameterOutProperties[0].ParameterDisplayName = "AliasTagList";
                  parametersOutProviderInitEventArgs.ParameterOutProperties[0].ParameterName = "AliasTagList";
                  parametersOutProviderInitEventArgs.ParameterOutProperties.length = 1;
                  
                  WPSC.RaiseConnectionEvent("MyParametersOutProviderInterface_WPQ_", "ParametersOutProviderInit", parametersOutProviderInitEventArgs);
                 }
                 function myMain()
                 {
                  try
                  {
                   aliasTagListToSend = "";
                   sAliasTagList = aliasTagList_WPQ_.split(';');
                   
                   if (aliasTagList_WPQ_ != "")
                   {
                    for (i=0; i < sAliasTagList.length; i++)
                    {
                     cb = document.getElementById("cbTagListDefaults_" + i);
                     if (cb.checked) aliasTagListToSend += sAliasTagList + ";";
                    }
                    aliasTagListToSend = aliasTagListToSend.substr(0,aliasTagListToSend.length-1);
                   }

                   parametersOutReadyEventArgs = new Object();
                   parametersOutReadyEventArgs.ParameterValues = Object();

                   parametersOutReadyEventArgs.ParameterValues[0] = aliasTagListToSend;

                   WPSC.RaiseConnectionEvent("MyParametersOutProviderInterface_WPQ_", "ParametersOutReady", parametersOutReadyEventArgs);
                  }
                  catch (ex)
                  {
                   j=0;
                  }
                 }
                }

                This is a tag picker webpart, displaying a list of tags (aliases) you can check off, and send to the RtTrend webpart as a comma separated list.