Monday, February 7, 2011

Creating a Simple web part

Here are the steps to create a simple web part in Visual Studio and deploy it into your sharepoint application:

Open Visual Studio and select a web part from project template.

Add Refrence:

Microsoft.SharePoint;

Now write below code:

protected override void CreateChildControls()
{
Lable lbl = new Lable();
lbl.Text="Hello To SharePoint Coding Blogs";
this.controls.add(lbl);
}

Build the Application.
Go to your project folder
And under Bin folder you will find .dll file.
Drag this .dll file into C:\windows\assembly

Now go to C:\inetpud\wss\Virtual Directory\your project name

Open web.config file

And under safe control tag put this code:

namespace= namespace name, Assembly=your assembly name, culture=nuetral
version=12.0.0.0, PublicKeyToken=7888etr77


Go to your Sharepoint application.
Site Actions->Siet settings

Under gallery section click on web part.
Click new.
Then select your class file and populate it.
Link
After that go to your site page and click edit page under site actions.

Click on add a webpart.
Select your webpart from web part gallery.

That's done.


For more please visit : www.sharepointcafe.net

No comments:

Post a Comment