3

Im embeding two webparts in my sharepoint page using page viewer. One part is UI which takes input from user and on submit it shud be passed to other web part and it should get refreshed. can anyone help with this?

1

2 Answers 2

1

You can connect two webparts by following link V-B mentioned in comment, however you can also use Ajax Update Panel in one webpart to get your work done but it depends on what your trying to do.

e.g. having 2 update panels selecting something in one panel will produce results in 2nd panel without any postback.

creating-update-panel-in-code-behind-dynamically

or

Ajax Panel in Sharepoint

1

If you want two webparts to talk to each other than you would need to make an Interface class. The interface class connects the consumer and provider class through inheritance.

Its quite easy but if you want to have an ajax updatepanel to performe a partial postback then that is a different ballgame its quite hard to figure out as its a hit or miss with sharepoint 2007 but for 2010 I think they have solved this issue! otherwise if you dont mind a post back than its perfect to share data between two or multiple webparts :)

So you have your interface class that basicly links the provider and consumer class that will inherit from it, once you have done the three seperate webparts or one webpart with three classes you can then connect the two webparts when editing the webpage!

so what you do in one webpart(provider) the other webpart would reflect the changes(consumer).

Here is a small tutorial, once you get your head around whats going on its easy:

http://www.codeproject.com/Articles/37142/Connecting-Custom-Web-Parts-in-SharePoint

EDIT

The interface is a class but its inherits the interface like so ;)

public interface ITextBoxString
{  
    string TextBoxString { get; set; }
}

As you can see this is in a seperate project in its own class that inherits the interface type, the class name is ITextBoxString

so all you need in the provider class is the following to inherit from this class:

public class StringProvider : WebPart, ITextBoxString

As you can see this is another project with a class called StringProvider that inherits from the base class Webpart and it also inherits from the ITextBoxString interface class!

I hope this explains where im comming from, thanks for the correction :)

hope this helps :)

7
  • Interfaces are not classes. Classes implement interfaces. msdn.microsoft.com/en-us/library/ms173156.aspx Aug 14, 2012 at 17:00
  • Yes I know that, I mean you create a seperate class for each one (interface, provider and consumer), you have two children classes that inherit from the parent class(interface). They are all seperate webparts in seperate projects within their own classes that you call ;).... I know considering I had to do it a couple of weeks ago for work ;) maybe I need to be more clear with my wording next time.
    – Ali Jafer
    Aug 14, 2012 at 20:26
  • I not implying the Interface that you inherit from is a class ;) just like on winforms inherit from like the base class... I wasnt talking about that if you read through the post youll notice im talking about the class and even state you inherit from the "type" interface in the interface class like so: public interface ICommunicationInterface and in the provider you have the class name then : ICommunicationInterface to inherit from the class you just made and so on..
    – Ali Jafer
    Aug 14, 2012 at 20:54
  • " you would need to make an Interface class. " I'd clarify that in an edit. Thanks. Aug 14, 2012 at 20:56
  • Thanks guys...but 1 more thing i have created webparts by giving url to my html pages(using that page viewer thing given in create webparts).So there are no provider n consumer classes for me. so is der any way to do without classes?
    – neal
    Aug 16, 2012 at 6:05

Your Answer

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

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