Free SharePoint WebPart – Simple, Generic Rollup WebPart

The client I am presently at has a comparatively large internal .NET shop since they are a .NET SaaS firm, and a lot of the traditional .NET developers are starting to migrate over to SharePoint for an internal product basis. So we figured the best way to train was to pick a pretty generic WebPart requirement, everyone builds their own, see who does what how, integrate the best approaches from the different projects, and see what the final product looks like.

Thus was born the Simple Rollup WebPart. It is named as such because it is literally the most generic WebPart that I have ever seen. And the requirement that was given was to make the World’s most generic WebPart. So this was successful!

In the spirt of being super generic, it is also really easy to use with a nominal amount of properties requiring configuration. Namely, there is:

  1. A URL
  2. A List Name
  3. A View Name
  4. Amount Up To Query
  5. Amount Down To Query

Noticably, the approach being used is much faster than traditional SharePoint rollups I have seen in the past, way past what the CQWP (Content Query WebPart) performs at.

Ok, so now to the screenshot-tastic demonstration of how the WebPart works. The WebPart is written in a Feature controlled format, following the same approach as nearly every other WebPart available on this site. So, firstly add the SharePoint Solution to the Solution store by running the installation .bat file:

10-22-2009 11-54-48 AM

After, the Solution will be available in the Solution store for deployment:

10-22-2009 11-53-40 AM

Once the solution is deployed, you have to active the Rollup Feature to populate the WebPart description file into the gallery so that you can add it to the page. Navigate to the Site Collection Features, and Active The Rollup WebPart Feature. 

10-22-2009 11-58-16 AM


Once Activated, you will find the WebPart available under the ARB Security Solutions group heading in the WebPart gallery:

10-22-2009 12-00-33 PM

Add it to the page, and you will be presented with the notification that no items have been found (because you haven’t configured the Rollup properties yet!)

10-22-2009 12-00-09 PM

Following, configure the properties for the WebPart. I have two Task lists on the primary and a subsite, so I am going to use that for testing. The properties are explained below:

10-22-2009 12-03-36 PM

  1. The URL to start the rollup at. If you leave this blank then it will use the current context as the starting point.
  2. The list name you want to query for, like “Tasks”, “Discussions”, etc.
  3. The levels up you want the rollup to go.
  4. The levels down you want the rollup to go
  5. The SharePoint view you want to target in the rollup, this allows you to target the data display to particular users since you have use the inherit view replacement variables, like [Me] and [Today].

Following, you will be presented with the columns and values based on those available in the configured view. The grouping is provided in order to split up the values by the site they are gathered from.

10-22-2009 12-08-37 PM

 And that’s it! The WebPart is free, but as always comments about use / backlinks are appreciated.


Link Will Be Back Up Shortly

Let me know if you have problems in the comments :)


Free Server Name WebPart Which WFE Is Servicing a SharePoint Request

This is probably the most nominal WebPart I have ever seen / written but I really needed it this morning. As you can guess it just uses a ServerVariables object (off the current context request) to expose the relevant environment variables, in this case just the server name.

The reason this came about was in large SharePoint farms it is notably important when doing certain types of architecture troubleshooting to know which WFE you are hitting. And….well…that’s really it. At least you don’t have to put the WSP together I guess.

So this is what that WebPart does. Just install the WSP and deploy it in Central Admin (as noted in previous posts, I never automate the deployment step).

10-13-2009 10-07-51 AMThe WebPart is Feature activated. In the site collection features, locate the Server Name WebPart feature and activate it.

10-13-2009 10-10-07 AM

Once activated, you will find the WebPart under the ARB Security Solutions header in the WebPart gallery.

10-13-2009 10-13-01 AM

Add it to the page, and it will display the server name in the SharePoint farm responding.

10-13-2009 10-13-51 AM


Well I guess I should actually give a download link :)



Building A Simple SharePoint 2007 / WSS v3 WebPart

First Steps In Creating A Simple SharePoint 2007 (MOSS) / WSSv3 WebPart

There are several differences that exist between the ways that WebParts were written in the SharePoint 2003 framework as opposed to the SharePoint 2007 (MOSS) framework that dramatically increases the functionality that is available to the developer. As written about in previous articles, there has been a dramatic shift in how WebParts are structured within the 2003 framework and the 2007 framework.

What Has Changed?

The way that WebParts are programmed in WSS 3.0 has changed drastically, however the benefits of programming WebPart instead of standalone .NET application remains the same. One of the most important things that is covered with the introduction of WSS 3.0 is the legacy style of creating WebParts (although both inherit from the WebPart class, in 3.0 this class is located in System.Web.UI.WebControls.WebParts namespace, and in WSS 2.0 this base class was located in the Microsoft.SharePoint.Pages namespace) is still maintained, and although the environment may have changed, programmatic efforts will not have been wasted. Since the new WebPart framework is based on the ASP.NET 2.0 framework, in order to maintain functionality and rendering capability there has been changes to the Microsoft.SharePoint.dll, referenced heavily when creating new WebPart projects.

WebPartManager Control

The most important concept to grasp in relation to developing ASP.NET 2.0 WebParts is the WebPartManager control (Note: this is in relation to ASP.NET 2.0 WebPart development, we will touch on the WSS 3.0 control responsibility for rendering shortly). This control serves a very important purpose in relation to the new technology of WebParts, mostly tailored around the serialization and de-serialization of WebPart related data since this data is transported from the database.

Starting to Create the WebPart

The first step in creating a new WebPart is to open the Visual Studio 2005 client (you can also use notepad if you wish to compile with the CSC command). You are then going to create a new project. When the project selection screen comes up, choose a class library, and then in language selection box choose either C# .NET or Visual Basic .NET, depending on yours or your client preferences. Name your project Hello World. When building SharePoint 2007 WebParts, and since it is common for the WebParts to exist within the GAC, you must modify your assemblyinfo.cs (or.vb) file in order to build the project with a signed assembly. This can also be done through the Visual Studio 2005 command prompt using the sn.exe command.

Open the class file that is located in your Visual Studio project. In this file, you will see at the top using statements (for the remainder of this article the examples will be provided in C#, but for brevity it will be imports statements or VB.NET). Through the use of adding references to this portion, will gain access to different options to inherit portions of code that would otherwise require several re-writes of code that is already placed into the framework.

Adding the Necessary References

The first reference that you will see in the default class library is the System. We will have to add other using statements in order to properly build other WebParts. Firstly, ensure the following references are made:

  • System
  • System.Web.UI
  • System.Web.UI.WebControls.WebParts

This should look like the following when added to your C# class file, located at the top before any other code (again, this should read imports …. if you are using VB.NET):


using System.Web;

using System.Web.UI;



Following, as explained before, we will have to change some of the inheritance so that our WebPart class will inherit out of the System.Web.UI.WebControls.WebParts namespace. Our class is called HelloWebPart, therefore we will have to create this inheritance by placing the following syntax.

Exposing SharePoint Specific Assets

For exposing certain SharePoint specific information and objects, there will have to be other references added to the project file. For the context of a Hello World WebPart, we are just facing text out of a WebPart, which doesn’t require access to the SharePoint object model, since in aggregate this is considered just an ASP.NET 2.0 WebPart. If for example, we wanted to query data out of a SharePoint list, we would have to add a reference to the Microsoft.SharePoint.dll, and then write some custom code to query the actual list. In order to setup access to the lists, you would have to first get the content of the current site as demonstrated below:


SPWeb HelloWorldTestSite = SPContext.Current.Web;


Then establish a reference to the list that we wish to query:


SPList Hellos = HelloWorldTestSite.Lists[HelloList];


In order to get all the items, there would have to be an enumeration set that would query through all of the objects of the list following:


foreach (SPlistitem Hellos in HelloList);

//Place your query logic here


Afterwards, you could massage the data as necessary and configure your display programmatically depending on your project requirements.

The Actual Hello World Code

Afterwards, to get our WebPart to render out some simple text, we will have to create some code that will parse out our message. It should look like the following when complete:


using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls.WebParts;

namespace helloworld {

public class helloworld : WebPart {

protected override void RenderContents(HtmlTextWriter writer) {

writer.Write (Hello World):





By placing the above code, you will get a simple SharePoint WebPart that when deployed will place the text Hello World within the WebPart.

Once built, you will get a simple assembly (or binary depending on semantics used within your organization), that can deployed to a SharePoint server pending some further modifications.

Deploying the WebPart for Use With Your Portal

There are two main locations where you can place a WebPart so that you can expose it to your users within your portal. The two places where a WebPart can be placed are:

  • GAC (Global Assembly Cache)
  • /bin directory of your SharePoint instance

For some organizations, placing a WebPart assembly within the GAC is not acceptable, since assemblies placed in this directory are run with full trust, and therefore not subject to several aspects of CAS (Code Access Security), so for the sake of this article we will deploy the WebPart to the local bin of the SharePoint site.

By default, your site collection will place relevant files for your SharePoint instance into your inetpub/wwwroot directory, where there is also a bin folder located, therefore the deployment path is inetput/wwwroot/bin for our SharePoint WebPart.

We can modify the path for where our WebPart is going to be deployed by going to the properties of the project (right click on the top level solution file from within Visual Studio.NET 2005 and select properties from the fly-out), where there are a great many other options outside of the deployment path, including setting the strong key that we are going to use. Under the build shuttle, under the output path, you can change the path to your SharePoint bin directory by placing the path C:\inetput\wwwroot\bin, where the final build will be placed.

Following, and similar to the architecture of SharePoint 2003, all WebPart have to have a safe control entry within the portal web.config in order to run correctly. This is an excellent feature since if there is a problematic WebPart that exist within your environment it is simple to switch it off in order to take it out of the entire environment until a remedy is implemented making it safe again for you to run.

Getting the WebPart to Appear On The Page

The steps in order to get the WebPart on your arbitrary SharePoint page are pretty straightforward. Navigate to the site actions menu on your site and go to the WebPart gallery. Select New which will allow you to add the newly deployed WebPart by selecting the checkbox next to your newly deployed project. Lastly, select the Populate Gallery option in order to deploy the WebPart for use within the portal.

Following, when you edit a page, you will be able to select the WebPart from the WebPart selection dialog through a variety of mechanisms including SharePoint designer and the GUI.