Walkthrough: Writing a Simple Filter Consumer Web Part Sample

SharePoint 2007

In this section, let's look at creating a simple filter consumer Web Part that displays the current filter value in the filter provider Web Part that is connected to it.

The steps we need to follow to create a simple filter consumer Web Part are:

  1. Create a ConsumerParameters interface instance to tell the filter provider about the parameter names. Windows SharePoint Services 3.0 will use this interface to populate the user interface for connecting the Web Parts at run time.

  2. Expose a Consumer connection point to request the IFilterValues interface from the filter provider Web Part.

  3. Use the interface in PreRender() and display the current filter value.

You can test this Web Part by connecting it to any out-of-the-box filter Web Part such as the Text filter. After you connect it to the Text filter, the simple filter consumer should display the value entered in the Text filter.

TipTip:

This Web Part can be very useful for seeing the filter values that are being passed from a filter provider, especially when you are debugging complex filters and consumer Web Parts. You can add it to your Web Part gallery to make it available for reuse.

Prerequisites

Before you write a filter consumer Web Part, you must set up your environment. This example assumes you have Microsoft Office SharePoint Server 2007 already set up and that you have a portal page where you can add Web Parts.

See Also

Community Additions

ADD
Show: