About      |       Articles      |      Services      |      Software      |      Contact

Latest Free SharePoint Software

ARB Security Solutions regularly releases free SharePoint software, including WebParts, Client Applications, Framework Extensions, and other Miscellaneous Components.
The most recent freeware is:

Title: Simple SharePoint Rollup WebPart
Date Published: 10/22/2009

Previous Two Free WebPart Releases:

SecureCenter For SharePoint

By SharePoint security integrators, for SharePoint security integrators.

SharePoint Security Assurance Program™

For externally facing SharePoint deployments, security is an acutely important deployment concern. Learn how through daily security scanning, you can ensure external business users and partners that they can collaborate in confidence!

Security Assurance WebPart:



Using WebPartPage, WebPartManager, and WebPart

There was a small question in the SharePoint development newsgroups that alluded to whether it was possible to use the SharePoint WebPartPage and SPWebPartManager objects in order to construct a small iteration through all the WebParts that were placed within an arbitrary WebPart page in a SharePoint instance and search for a specific WebPart type. The objects that will be exposed in this code example are pretty straightforward, notably:

WebPartPage - Represents a SharePoint WebPart page

SPWebPartManager - Derived from the ASP.NET 2.0 WebPart manager, the SPWebPartManager object manages all the WebParts and WebPart zones on a page.

WebPart - Represents, well you know, a frickin WebPart on the page

In this example, I will show you how to use the aforementioned objects, and then show you to how to build the loop that was the main part of the persons query in the newsgroups.

Here is the code, in this I will test for the most standard WebPart type, a ListViewWebPart, since it is orthodox and out-of-the-box.

C#:
  1. if (!string.IsNullOrEmpty(this.SPWebPartManager))
  2. {
  3.  
  4. WebPartPage l_oPage = (WebPartPage) this.Page;
  5. SPWebPartManager l_oManager = (SPWebPartManager) l_oPage.Master.FindControl(this.SPWebPartManager);
  6. if (l_oManager.DisplayMode.Name.Equals(WebPartManager.BrowseDisplayMode.Name))
  7. {
  8. foreach (WebPart l_oPart in l_oManager.WebParts)
  9. {
  10. if (l_oPart.GetType() != typeof(ListViewWebPart))
  11. {
  12. // Perform some action after the type test is complete, depending on your type return
  13. }
  14. }
  15. }
  16. }

  • Share/Bookmark

4 Comments »

  1. Hello!
    I am trying to connect two DataFormWebPart. Any ideas?
    I get SPLimitedWebPartManager, but it is not helpfull. Please, help me!

    Comment by Elena — December 3, 2007 @ 11:11 am

  2. Hi Elena,
    you should do something yourself too rather than asking here and there …hopefully now you will look in your problem more seriously :)

    Comment by smith — January 8, 2008 @ 1:25 am

  3. smith is right in saying so…!! ;)

    Comment by angela — January 8, 2008 @ 1:28 am

  4. big assumption there, smith

    Comment by Terry — January 13, 2009 @ 1:24 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment