Thursday, June 16, 2011

Sharepoint 2010 WebPart Tutorial

 

Webparts as you know are Reusable components that can be deployed and added to many different sharepoint site pages. In this post we will talk about custom and Out-of-box webparts in SharePoint 2010.


In sharePoint 2010 we can create two kind of custom WebParts :


1. Visual WebPart - While creating a Visual webpart you will have a design interface available with you, where you can simply drag and drop checkboxes, labels or your own custom controls to make up the webpart UI. To add the business logic, a code behind file is also attached to the webpart.
Technically, a Visual webpart in SharePoint 2010 is a ascx User Control that is hosted inside a standard asp.net webpart. If you notice that the webpart class does not now inherit form a Microsoft.SharePoint.webpartpages.webparts or System.Web.UI.WebControls.WebParts instead it inherits from UserControl namespace.


2. Standard AsP.NET WbeParts - Here you will have to build uo your user interface and logic in a class file. Unlike, visual webpart standad asp.net webparts in SharePoint 2010 does not gives you any drag and drop design surface for developing WebPart UI. This type of webpart Inherits from Standard ASP.Net webpart instead of UserControl or SharePoint.webpart.

WebPart Packaging -
Visual Studio 2010 package and deploy webparts when you press Clt + F5. It has a packaging and deployment processor which will create the needed solution package for your webpart and will deploy it in your sharepoint site. You can then add the webparts on any sharepoint site page from webpart gallery.

No comments: