PtiTom

SharePoint Text Filter Consumer

Jan 18th, 2013
74
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace FilteredWebPart.SampleFilterWebPart
  2. {
  3.     [ToolboxItemAttribute(false)]
  4.     public class SampleFilterWebPart : WebPart
  5.     {
  6.         private string addedString;
  7.  
  8.         protected override void CreateChildControls()
  9.         {
  10.             if (string.IsNullOrEmpty(this.addedString))
  11.             {
  12.                 this.Controls.Add(new LiteralControl("Salut !"));
  13.             }
  14.             else
  15.             {
  16.                 this.Controls.Add(new LiteralControl(string.Format("Tu crois vraiment que je vais chercher '{0}' pour toi ?", this.addedString)));
  17.             }
  18.         }
  19.  
  20.         [ConnectionConsumer("filter")]
  21.         public void SetFilter(IWebPartField filterValues)
  22.         {
  23.             if (filterValues != null)
  24.             {
  25.                 FieldCallback callback = new FieldCallback(ReceiveField);
  26.                 filterValues.GetFieldValue(callback);
  27.             }
  28.             else
  29.             {
  30.                 this.addedString = string.Empty;
  31.             }
  32.         }
  33.  
  34.         public void ReceiveField(object objField)
  35.         {
  36.             if (objField != null)
  37.             {
  38.                 this.addedString = (string)objField;
  39.             }
  40.         }
  41.  
  42.     }
  43. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×