Skip to Main Content
Essential SharePoint 2007, 2nd Edition
book

Essential SharePoint 2007, 2nd Edition

by Jeff Webb
September 2007
Beginner content levelBeginner
448 pages
10h 2m
English
O'Reilly Media, Inc.
Content preview from Essential SharePoint 2007, 2nd Edition

Connecting Parts

A web part that can exchange data with another web part is connectable. You create a connectable web part by completing these major tasks:

  1. Define an interface for the connection.

  2. Implement the interface in the connection provider web part.

  3. Add a connection point to the provider web part.

  4. Add a connection point to the consumer web part.

The interface defines the type of data used by both the provider and consumer web parts. The following code shows a very simple interface for exchanging text data between web parts:

// 1) Interface used for text connections.
public interface ITextProvider
{
    string TextConnection { get; }
}

The web part providing the connection must implement this interface and supply a method that returns the connection point. The following code shows a very simple web part that provides a text connection:

 [Guid("C4288D94-D8F0-4f8f-8443-3A40F05E6B92")] public class ConnectProvider : WebPart, ITextProvider // 2) Implement interface { // 2) Implement interface. #region ITextProvider Members public string TextConnection { // Return Text property. get { return this.Text; } } #endregion // 3) Add provider connection point. [ConnectionProvider("TextConnection")] public ITextProvider ConnectionProvider( ) { // Return this web part. return this; } // Web part UI. #region WebPart properties and controls const string defaulttext = ""; private string text = defaulttext; [Personalizable(PersonalizationScope.Shared)] [Category("Custom")] [WebBrowsable(true)] [WebDisplayName("Text")] ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Microsoft® Office SharePoint® Server 2007 Best Practices

Microsoft® Office SharePoint® Server 2007 Best Practices

Ben Curry, Bill English
SharePoint 2007: The Definitive Guide

SharePoint 2007: The Definitive Guide

James Pyles, Christopher M. Buechler, Bob Fox, Murray Gordon, Michael Lotter, Jason Medero, Nilesh Mehta, Joris Poelmans, Christopher Pragash, Piotr Prussak, Christopher J. Regan

Publisher Resources

ISBN: 9780596514075Errata Page