Advertisement
PtiTom

SharePoint Text Filter Consumer

Jan 18th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement