MOSS 2007/WSS 3.0 Service Pack 2 Released!

29 04 2009

The Microsoft SharePoint Team have just released Service Pack2 for SharePoint 2007 and WSS 3.0. It includes all the cumulative updates through Feb 09 as well as bug fixes and various performance improvements.

Links to the downloads are on the SharePoint Team Blog:

Have Fun! 🙂

Creating a WSS/MOSS Web Part – The Basics

29 04 2009

I’ve created this simple guide to demonstrate the various files that you need to create and how to structure your Visual Studio solution in order produce a WSS/MOSS Web Part.

1) Create a new Class Library (dll) project in Visual Studio

2)Name your class file appropriately:


3)Add a reference to the Microsoft SharePoint dll and strongly sign the assembly (Project –> Properties –> Signing –> Sign the assembly)

4)Create the following folder structure in the solution:


5)Create a folder under features with the name of your web part

6)Create the following files under the feature folder:


7)Place the following code into the .webpart file:

    <webPart xmlns="">
            <type name="DemoWebPart.DemoWebPart, DemoWebPart, Version=, Culture=neutral, PublicKeyToken=ec278ac1962b4ce0" />
            <importErrorMessage>Cannot import Custom CascadingNav Web Part.</importErrorMessage>
                <property name="Title" type="string">Demo Web Part</property>
                <property name="Description" type="string">Demo Web Part</property>

Where type name contains the namespace.classname and the full assembly name of your dll. Also set your title and description here.

8)Place the following code in the ElementManifest.xml file:

<Elements  xmlns="">
    <Module Name="WebParts" List="113" Url="_catalogs/wp" >
        <File Url="DemoWebPart.webpart" Type="GhostableInLibrary" />

Ensure that the ‘File Url’ matches the name of the webpart file created in step 6.

9)Put the following code in the Feature.xml file:

<Feature Title="DemoWebPart" Id="74BE3173-91B7-4ef7-B50A-E31357885176" Description="" Version="" Scope="Site" Hidden="FALSE" DefaultResourceFile="core" xmlns="">
        <ElementManifest Location="ElementManifest.xml" />
        <ElementFile Location="DemoWebPart.webpart" />

Make sure you create a new GUID for the ID and specify the correct ElementManifest and ElementFile names.

10)Your Web Part is now ready, you can now add your code to the cs file. Once finished, build the solution, copy the dll to the GAC folder we created under the solution and build the WSP folder using the WSPBuilder tool (

Hope this helps! 🙂

Creating SharePoint/WSS View Programmatically

23 04 2009

Using the object model it is really easy to create a SharePoint view programmatically in code and then add it to a list. This code could be executed from a workflow for example to create a dynamic view as required. The query for the view uses an SPQuery which uses CAML. Personally I like to use the U2U CAML Creator application to create the CAML query for me which was created by Patrick Tisseghem (


//Define an array to hold the columns required in the view

String[] colArray = new String[] { "Column1", "Column2", "Column3” };

//Add the array to a string collection

StringCollection colCollection = new StringCollection();


//Define the query for the view

String viewQry = “Your CAML Query Here’;

//Define the new view & Add to the List (100 is the item limit, true is allow paging and false is to set as the default view)

SPView newView = YourList.Views.Add(“View Title”, colCollection, viewQry, 100, true, false);

**End Code**

Success, your view should now be visible in the list!

Hope this helps someone! 🙂

What I am working on – Coming Soon

21 04 2009

Dear Readers,

I thought I would write a quick post as I haven’t blog posted for a while. I am currently working on some code to create list views dynamically in code using the SharePoint object model and will post an example up when I’m done.

Additionally I am currently customising the Cascading Navigation Web Part ( that was created by Yvonne Harryman to add more rich functionality.

The Cascading Nav Web Part allows you to configure and display a drop down top menu on WSS sites (a feature that present in full blown MOSS). I will contact Yvonne to provide a new release with the additional content.

On a separate note, did everyone have a good time at the SharePoint Best Practices Conference in London, UK? I sadly could not attend but from what I hear there were some very informative sessions/presentations.

More to follow soon…


Hide ECB Menu Item in SharePoint Lists

10 04 2009

Let’s face it, the SharePoint ECB menu contains lots of items that may not be required for a simple system.

It is possible by creating a custom version of the CORE.JS file to hide any required menu items from the ECB drop-down menu – betware though this will hide it for the entire site collection.

Let’s say we want to hide the ‘Check Out’ option:


Make a copy of the CORE.JS file from the following location on the SharePoint Server:


Name this copy CUSTOMCORE.JS. Next open this file with SharePoint Designer or a standard text editor, find and comment out the following line:

AddCheckinCheckoutMenuItem(m, ctx, currentItemEscapedFileUrl);

Save the file and now open your master page (normally default.master). You will probably need to do this with SharePoint designer, add the following line to the head of the page:

<SharePoint:ScriptLink language="javascript" name="core.js" Defer="true" runat="server"/> <SharePoint:ScriptLink language="javascript" name="customcore.js" Defer="true" runat="server"/>

Save the masterpage and head over to your SharePoint site, you should now see that the ECB menu is missing the ‘Check Out’ option:


You can do this with each of the menu items that you need to hide, simply comment out the ‘Add’ code for the menu item – e.g. The workflows method is AddWorkflowsMenuItem.

Hope this helps some one! 🙂


If you want to hide the Check Out menu item from All users you will need to publish a Major version of the master page in the ‘Masterpage Gallery’ of the site. Simply click edit properties (because we can no longer check out using the menu! – unless you sign in as a different user of course), check out then check back in. You will then get the option to publish a major version, once this has been approved it will be available to all users.

WSS – Get User Profile Details Programmatically

6 04 2009

In WSS, there is a basic list called the ‘User Information List’ which holds some profile details about the users themselves. These details can be viewed/edited from the ‘My Settings’ screen.


WSS holds the following user details:

  • Account (Login Name)
  • Name (Display Name)
  • E-Mail
  • About Me
  • Picture
  • Department
  • Job Title
  • SIP Address

You can get a reference to any of these properties in code simply by querying the list with the ID of the required SPUser:


using (SPSite Site = new SPSite(“Site URL”))

  using (SPWeb Web = Site.OpenWeb())

SPList UserInfoList = Web.Lists[“User Information List”];

SPUser User = Web.Users.GetByID(1); – Put the User ID Here

SPListItem UserItem = UserInfoList.GetItemById(User.ID);

UserItem[“Department”] = “Some Department”;



Using this list you can set any of the values as required or simply retrieve the stored values. I used the above to get a reference to the ‘Picture’ which is stored as a URL.

Happy Coding! 🙂

MOSS/WSS Application Pool Best Practices

1 04 2009

Dear readers,

We have a small WSS deployment that we are currently trying to re-organise, we have about 4 or 5 SharePoint application pools for various web applications and the central admin site itself. I decided to look for some best practices for these application pools to try and speed things up, I found this blog post by Joel Oleson – All I can say is thank you Joel!

He talks about the correct settings to use for SharePoint app pools – both performance and health. After applying the said settings to ours we have noticed a big speed increase on the server. I recommend you all take a look to make sure your application pools are running effectively.