Search This Blog

Monday, June 1, 2009

Developing a Custom Web Part with Microsoft Visual Studio 2008

With the release of Microsoft Visual Studio 2008 many SharePoint Developers will be interested in creating custom Web Parts for SharePoint. This is entirely achievable and not very different from how it is done within Visual Studio 2005.

While the avenues to accomplishing this are similar with Microsoft Visual Studio 2005, there are a few items to consider:

  • Visual Studio 2005 Extensions for Windows SharePoint Services is not available or compatible with Microsoft Visual Studio 2008
  • As a good practice, it is recommended to backup your project before converting it into Visual Studio 2008

Creating the Web Part Project can be done in two of ways:

  • Convert an existing template project from Microsoft Visual Studio 2005
  • Create the project from scratch
    • Add the following references to the project:



    • Add the following code to the top of the project

      using System.Web;

      using System.Web.UI;

      using Microsoft.SharePoint.WebPartPages;

    • Assign the class to inherit from the WebPart

    MyCustomWebPart: WebPart

    • Add the RenderWebPart code:

    void RenderWebPart(HtmlTextWriter output)



    • Add desired code inside the "RenderWebPart"
    • Determine deployment type: bin or Global Assembly Cache
    • By default the Target Framework is 3.5
    • Deploy the Custom Web Part

1 comment:

  1. Hi! Pretty post and really impressive thinking,I like the presentation,your style of writing.The informations are really helpful for the newbies like me.Thanks for the fabulous information.Keep up blogging continue.........:)