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! 🙂




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: