Thursday, February 12, 2009

Sharepoint Webpart Development Part 1

Here we can discuss about Sharepoint web part development.

  • Open Visual Studio.Add new project.
  • Either you can use Web Part Template in Visual Studio by selecting WebPart project while adding new project or alternatively you can simply create a class library and inherit class from System.Web.UI.WebControls.WebParts.WebPart or Microsoft.SharePoint.WebPartPages.WebPart(Needs Microsoft.Sharepoint.Dll).

  • public class TestWebPart : Microsoft.SharePoint.WebPartPages.WebPart
    {
    public string FirstName{ get; set; }

    protected override void Render(System.Web.UI.HtmlTextWriter htmlTextWriter)
    {
    base.Render(htmlTextWriter);

    //Custom Render Code comes here.//
    }
    }
    So property FirstName will be showed in the property grid editor with a textbox.If you have a boolean property it'll be showing as checkbox in the property grid of the web part.For enumeration it'll be DropDownlist.So it have default Tool Part behavior.But we can create custom Tool Part in web part.

    That I'll show in the next post.

    0 comments:

    Post a Comment