Visit our SharePoint Forum

SharePoint developer? Submit Yourself as Freelancer

Tuesday, February 19, 2008

Deploy a WebPart in Sharepoint Site

See Step-by-Step example Here
There are many ways to deploy a Webpart in SharePoint sites.
The easiest method is, when you want to deploy a "Sharepoint Webpart" in a given SharePoint site.

Lets Disscus this easy method:

To Deploy a Sharepoint webpart ,folow the steps below:

1. Create a Sharepoint Webpart Project. The Code for which would look like:

using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;

namespace Web_part1
public class Web_Part1 : System.Web.UI.WebControls.WebParts.WebPart
public Web_Part1()
this.ExportMode = WebPartExportMode.All;
protected override void Render(HtmlTextWriter writer)
writer.Write("Hi, This a test for WebPart deployment!");
} }

2. Next we will give the Assembly, a Strong name by assigning it a Public key value. To do that Right Click on the project title(in Solution Explorer Window) and go to Properties.
Go to Signing tab, and select a key in dropdown Or you can create a new public key(using sn.exe tool) and then browse it in "signing key file name" field.

3. Now go to Debug tab and select "Start browser with Url" option and write the url of the Sharepoint site, where you want to deploy the Webpart.

4. And now you are all set, Just right click on the project in Solution Explorer again and click deploy.

5. Open the sharepoint site and add a new WebPart page(Site Settings->WebPart pages). ADD a your Webpart into the site and you would see the message "Hi, This a test for WebPart deployment!"

See Step-by-Step example Here


emolikeamother said...


I am trying to deploy your Mini Calendar that is posted on CodeProject. I am coming across a problem when deploying:

The "WebPart_Calendar_Class" Web Part appears to be causing a problem. Value does not fall within the expected range.

I am not sure what is going wrong as when I build and deploy to sharepoint, there are no errors.

Anonymous said...

I get an error saying feature "guid" is not installed in this farm, and can not be added to this scope.

Isha kapoor said...


Check the internal names of the fields u are using

Sharepointdeveloper said...

Hello Isha...I have followed the steps mentioned and it works fine and every thing is good...

I have a problem here....
If I want to deploy the webpart to multiple sites in my local can i do that?

Isha kapoor said...

Deploy WebPart as Solution package .... that will solve ur issue

Anonymous said...
This comment has been removed by a blog administrator.
SPDevJr said...

I need some info:
1) I deploy a new Web Part and deploy it to a site. Next, I need to modify that web part and deploy its new version. How do I do that?
2) The new version web part deployment goes wrong. Do you I revert back to the old version?


Anonymous said...
This comment has been removed by a blog administrator.

SharePoint Programming