Search code examples
sharepointdependenciesweb-partsbll

Sharepoint Web Part Management


I have a rather large project developed on Sharepoint and Project Server, designed as a multi-tier application. I programmatically manage web parts on certain web part pages. According to the choices of the user in one of the web pages, appropriate web parts are added to the web part collection of another web part page. My problem is that I simply do no know where to manage the web parts, should I do it in the BLL and then have the assembly containing the business logic reference the UI assembly where the web parts are? (I need to instantiate the web parts when adding them to the collection, since I do not want to use hard coded strings representing the web part dwp.)


Solution

  • It really depends on what pattern you're using for your BLL and UI layers, and how strictly you want to follow it.

    If you're doing a MVP pattern then I'd suggest that you have the Page implementing an interface which has one (or more) of the following options:

    • A stack which the Presenters to load are added to
    • A Load_WebPartName event for each web part which then should be called to indicate which webpart(s) need loading

    To be strictly MVP you should not reference the following assemblies in your BLL project:

    • System.Web
    • Microsoft.SharePoint
    • Microsoft.SharePoint.*

    (All SharePoint assemblies would be in either the Model or UI projects, the BLL is just connecting to the appropriate hocks)