1

I just finished this tutorial, pretty simple.

But I also found this other one talking about the same topic.

What I don't understand is what's the difference and when should I use one method or the other? The first one is pretty simple using an Interface with some properties, and then on the consumer declare an object of the Interface type and that's it.

The second example is very complex to me, and I don't know in which case I should use which.

2 Answers 2

2

The major difference in these approaches is that in the second approach the interfaces listed here are specific to SharePoint so these would only work when you are developing SharePoint web parts but the first example is generic and is SharePoint independent.

In scenarios where you just need to supply couple of values, you should go with the first example, i.e. defining a common custom interface. This is handy and easy to implement/understand.

The second scenario is complex as it provides more options to you with respect to SharePoint. For instance, if you have a datagrid in your provider web part and you wish to provide the functionality of sending multiple rows as selected by a user to your consumer web part, then here you should go implementing the OOB IRowProvider, IRowConsumer interface which lets a web part to provide or consume a single row (or multiple rows) of values.

1

I'm not familiar with this area of Sharepoint, but after looking through those links, it appears that they are actually closely related. Here's my take on it:

  • The simpler tutorial shows you how to create linked web parts by using a simple interface you define in your own code - IProject - which has nothing but an ID and a name

  • The advanced tutorial shows you how to create linked web parts by using a complex interface that is predefined and part of the Sharepoint DLLs - ICellProvider - which has properties as well as events and methods that must be implemented

(read those two bullet points a couple of times and compare them so that you are clear on the difference)

Either way, you end up with a web part producer that implements some interface, and so long as you have another web part consumer that implements the same interface, you're set.

To more directly answer your question: The first (simple) tutorial describes how you can create your own custom interface, which would only let you connect a web part you create to another web part you create.

The second (complex) tutorial describes interfaces that you can implement that will let you connect your custom web part to existing web parts that already exist in Sharepoint (such as list web parts, etc.).

Caveat: I'm not certain of anything I've written here - this is merely conjecture based on a reading of the two articles you linked to. It's my best guess.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.