Creating a WebPart that works both as a consumer and a provider
If you ever have to create a web part that needs to act both like a provider and a consumer in which case you'll need to implement more than one Interface, you'll need to create separate classes that implement the separate interfaces...
To make a web part work both as a provider and a consumer you'll need to create three classes...
1) public class CellProviderInterface : ICellProvider
2) public class CellConsumerInterface : ICellConsumer
3) public class WebPart1 : Microsoft.SharePoint.WebPartPages.WebPart
In classes CellProviderInterface and CellConsumerInterface you'll have to implement the ICellProvider and ICellConsumer interfaces.
In your WebPart class you need to instantiate the two classes that implement the ICellProvider and ICellConsumer (viz. CellProviderInterface and CellConsumerInterface)
//instantiate your classes
CellConsumerInterface oCellConsumerInterface = new CellConsumerInterface();
CellProviderInterface oCellProviderInterface = new CellProviderInterface();
And When you register your interface's in the overridden EnsureInterfaces() you need use the instances of these two classes.
public override void EnsureInterfaces()
{
// Register the ICellProvider interface
RegisterInterface("CellProvider_WPQ_",
"ICellProvider",
WebPart.UnlimitedConnections,
ConnectionRunAt.Server,
oCellProviderInterface,
"CellProvider_WPQ_",
"Provides a cell to",
"Provides a cell of data");
// Register the ICellConsumer interface.
RegisterInterface("CellConsumer_WPQ_",
"ICellConsumer",
WebPart.UnlimitedConnections,
ConnectionRunAt.Server,
oCellConsumerInterface,
"CellConsumer_WPQ_",
"Consumes a cell from",
"Consumes a cell of data");
}
Here’s some sample code that does something very similar….
https://msdn.microsoft.com/library/default.asp?url=/library/en-us/spptsdk/html/smpxCreateConnectableWPMultipleInterface_SV01080585.asp?frame=true
Jeelani
Comments
Anonymous
July 23, 2006
The comment has been removedAnonymous
November 15, 2006
-- Build to Perform, Architect to Evolve -- I do not agree. Go to http://www.hotelsforum.info/amid_United%20Kingdom/tetter_England/wiry_Bournemouth_1.htmlAnonymous
November 17, 2006
-- Build to Perform, Architect to Evolve -- I do not agree. Go to http://www.hotelscenter.info/nub_United%20Kingdom/recast_England/bred_Bedford_1.htmlAnonymous
January 19, 2007
-- Build to Perform, Architect to Evolve -- I do not agree. Go to http://www.buyemployments.info/alien_Germany/accompaniment_Th%C3%83%C2%BCringen/isoseismal_Weimar_1.htmlAnonymous
March 28, 2007
-- Build to Perform, Architect to Evolve -- I do not agree. Go to http://www.getworkz.info/boy_United%20Kingdom/pyroxene_England/aerodrome_London_1.htmlAnonymous
August 14, 2007
-- Build to Perform, Architect to Evolve -- I do not agree. Go to http://apartments.waw.pl/Anonymous
February 07, 2008
Mohammed I've been trying to build a provider/consumer web part using the approach you outline in this blog. However, I am having some difficulty. The link to the example is broken. Can you update the link or provide a working example? I realize this approach is now obsolete, but unfortunately, I'm stuck with obsolete development and operational environments. Any help you can provide will be greatly appreciated. Mike Michael.Cottenier@us.army.milAnonymous
January 21, 2009
PingBack from http://www.keyongtech.com/1976306-a-web-part-that-isAnonymous
January 22, 2009
PingBack from http://www.hilpers.fr/942420-wss2003-webpart-cell-provider-et