Creating connected webparts involves the below steps.
Create an Interface
public interface ITextBoxString
Create a property which would be returning a reference to the interface.
public interface ITextBoxString
{
string TextBoxString { get; set; }
}
Provider Webpart
Implement the interface.
public class StringProvider : WebPart, ITextBoxString
create a property which would be returning the interface reference decorate it with ConnectionProvider
[ConnectionProvider("Provider for Text Value", "TextBoxStringProvider")]
public ITextBoxString TextBoxStringProvider()
{
return this;
}
Consumer web part
It should contain the method which would receive the interface.The method should be decorated with ConnectionConsumer attribute.
[ConnectionConsumer("String Consumer", "StringConsumer")]
public void TextBoxStringConsumer(ITextBoxString Provider)
{
_myProvider = Provider;
}
public void TextBoxStringConsumer(ITextBoxString Provider)
{
_myProvider = Provider;
}
YOU ARE ALL SET!