Sharepoint WebParts

Let's say you have several web pages, one as a controller and several that take information from the controller and act on it. This is fairly easy to model using the Consumer / Producer interface introduced in ASP 2.0.

How could you add interactions to each other while preserving all of the above?

A simple example would be: a user enters information into web page A, which searches, and the results will be displayed in web part B. Webpart C allows you to filter the results that web part A must call to resend the request, and therefore refresh the results in B.

In WSS 3.0, this cannot be done because you are only allowed one interface that will be used in all connections at any given time.

Does that even make sense ?:-)

+5
source share
2 answers

A quick and dirty solution that allows for arbitrary control communication is to use recursive search and event control. Ask the controls to search the control tree by type of control for their needs, and then subscribe to public events in the publication control.

Earlier, I used the trick so that standard server controls would find each other when embedding into CMS systems from different vendors to completely exclude a specific communication interface.

+2
source

-. webpart B / / / . : EnsureChildControls. , - PreRender, - CreateChildControls.

- A webpart B ( - B Calendar), :

     private Calendar _calendarWP = null;
    public Calendar CalendarWP
    {
      get
      {
          if (_calendarWP != null)
              return _calendarWP;
          else
              foreach (System.Web.UI.WebControls.WebParts.WebPartZone zone in this.WebPartManager.Zones)
                  foreach (System.Web.UI.WebControls.WebParts.WebPart webpart in zone.WebParts)
                      if (webpart is Calendar)
                      {
                          _calendarWP = (Calendar)webpart;
                          _calendarWP.EnsureChildControls();
                          return _calendarWP;
                      }
          return null;
      }
    }

, , :

         IEnumerable newData = SomeDataProvider.GetNewData(args);
        CalendarWP.someGridView.DataSource = newData;
        CalendarWP.someGridView.DataBind();

, , webpart A webpart B, webpart. / , :

CalendarWP.UseWPAToFetchData(this);
+1

All Articles