Creating a Web Part Project

Before you can start writing code for a web part, you need to set a few things up so that you can debug and test the component from within SharePoint:

  1. Create a test page in SharePoint.

  2. Create and configure a new project.

  3. Build and sign the assembly; then extract the token.

  4. Register the web part Web.config.

  5. Add the web part to the test page to verify that everything works.

The following sections describe these tasks in more detail.

Creating a Test Page

Since web part projects are class libraries, they require a context within which to run. It is a good idea to create a document library of web part pages on your development server for debugging and/or testing purposes. Using a document library helps organize the test pages and makes it easier to create/modify them.

To create a test web part page library:

  1. From SharePoint on the development server, choose Create Document Library. SharePoint displays the New Document Library page.

  2. Enter the name TestPages, select the Web Part Page document template, and choose Create. SharePoint creates a new document library.

  3. Choose New Document to create a new, empty web part page named Test1.

  4. Write down the address of the new page. You'll use that address when configuring the project.

Configuring a New Project

To create and configure a new web part project in Visual Studio:

  1. From Visual Studio, choose File New Project, select the Web Part Library template from the Visual Basic .NET or Visual C# project type, and choose OK. Visual Studio ...

Get Essential SharePoint now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.