How to deploy a custom webpart to SharePoint 2010 site ?

This article will describe about the deployment steps of a custom web part to SharePoint 2010 site. This is very simple, just like coding and few sharepoint knowledge. You need to do coding for webpart in visual studio and then deploy it into SharePoint 2010 site.

Deploy a custom web part to SharePoint 2010 site:

First open visual studio and create an empty SharePoint project.
Give correct SharePoint site path when asked and you can create a project at farm level or sandbox solution both based on your privileges.

Once you complete these steps then from solution explorer add new item and add a new web part. Give a name to your web part.

Now copy this code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
Label lbl = new Label();
lbl.ID = "lblTime";
lbl.Text = DateTime.Now.ToString();


Now build your application.

Now from solution explorer right click on project name and select deploy.

Once your deployment process will succeed then your respective SharePoint site will open in a new browser window.

Now from Site Action select Edit Page.
Then on the page click on 'Add a web part'.
From the category select 'Custom' and then select your web part name from the group.

And click on 'Add'.
Your web-part will be added to your page.


Guest Author: Ramakrishna08 Feb 2012

it is help full to me thanks

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: