How to: Create a SharePoint Web Part

To create a Web Part, add a Web Part item to any SharePoint project. To add controls to a Web Part, edit the Web Part code file.

You can also design a Web Part visually by using a designer. For more information, see How to: Create a SharePoint Web Part by Using a Designer.

To create a SharePoint Web Part

  1. Create a new SharePoint project, or open an existing SharePoint project. For more information about SharePoint projects, see SharePoint Project and Project Item Templates.

  2. In the Add New Item dialog box, in the Installed Templates pane, expand the SharePoint node, and then click 2010.

  3. In the list of SharePoint templates, select Web Part, and then click Add.

  4. In the Name box, type a name for the Web Part, and then click Add.

    The Web Part item appears in Solution Explorer. For more information about the files included in a Web Part item, see Creating Web Parts for SharePoint.

  5. In Solution Explorer, double-click the Web Part code file. For example, if the name of your Web Part is WebPart1, double-click WebPart1.vb (in Visual Basic) or WebPart1.cs (in C#).

    The Web Part code file opens in the Code Editor.

  6. Add controls to the CreateChildControls method of the Web Part code file. For an example, see Walkthrough: Creating a Web Part for SharePoint.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2015 Microsoft