Create WebPart in sharepoint
In this article I am going to explain you that what is web part in share point and how to create it.
A Web Part, also called a Web Widget, is an ASP.NET 2.0 server control which is added to a Web Part Zone on Web Part Pages by users at run time. The controls enable end users to modify the content, appearance, and behavior of Web pages directly from a browser. It can be put into certain places in a web page by end users, after developing by programmer.
SharePoint 2007вЂ™s portal infrastructure uses the ASP.NET Portal Framework classes as base classes. The heart of SharePoint development is in the WebPart class. the System.Web.UI.WebControls.WebParts.WebPart class is what you must derive from to develop web part.
I will take a sample program to display some text on sharepoint page using webpart.
To do so i will be using Render method. However we can also use CreateChildControl method.
Basically when we are rendering some html stuff then we should use Render method. But when you require to load some control like DropDownBox or control with events then we should use CreateChildControl method.
Deploy web part using feature:-
To deploy web part using feature in sharepoint we need to create below 4 files:-
1. webpart c# class which we have created in sample program already.
2. .webpart file which includes webpart information.
3. feature xml file.
4. Element xml file.
See below solution structure which will explain you how to keep files and in which structure:-
Note: This solution has beenВ created by using WSP builder template. So you will have вЂњWSP BuildвЂќ on right click of solution file. By doing this WSP Builder will take care to add safe control entry in web.config file. You need not to worry about. Just deploy this WSP, will work for you.
See Below Image which shows option to build WSP:-
Once WSP is ready; you can deploy this using stsadm commands.
Stasdm commands should be in below sequence
1. Retract Solution
2. Delete Solution
3. Add Solution
4. Deploy Solution
Detail of these commands can be view at below url
TechNet StsAdm Commands
Note: please visit my other article for How to create custom property for sharepoint web part.
April 1, 2012
В· Infoyen В· One Comment
Tags: Create Custom Web Part in SharePoint, Developing and Deploying Custom Web Parts for SharePoint, Developing Sharepoint 2007 Custom Web Parts, MOSS, SharePoint, sharepoint web part development, SharePoint: Creating Custom Enterprise Search Web Parts, Write Custom WebParts for SharePoint 2007 В· Posted in: MOSS, SharePoint, WebPart