Uređivanje

Dijeli putem


Create a SharePoint Web Part by using a designer

You can create a web part by adding a Visual Web Part item to any SharePoint project. This opens the Visual Web Developer designer in Visual Studio where you can add controls and code to the web part. Visual web parts function the same way as web parts do. The only difference is that you design visual web parts in the Visual Web Developer designer.

To create a project for visual web parts

  1. On the menu bar, choose File >New > Project.

  2. On the Create a New Project dialog select the SharePoint Visual Web Part* for the particular version of SharePoint you have installed. For example, if you have SharePoint 2019 install select the SharePoint 2019 - Visual Web Part template.

    Note

    You can also search for templates by typing SharePoint in the Search text box at the top of the Create a New Project dialog. You can also filter the list of templates to show only the templates for Office and SharePoint by selecting "Office" in the Project type drop-down box. For more information, see Create a new project in Visual Studio.

  3. Change the name of the project if you would like to, and then choose the Create button.

  4. On the Specify the site and security level for debugging page, specify the URL of a SharePoint site that's on the local computer, and then choose the Finish button.

    In Solution Explorer, a web part appears. After designing the web part in the Visual Web Developer designer, you'll test it on the site that you specify.

To add a visual web part to an existing SharePoint project

  1. On the menu bar, choose Project > Add New Item.

  2. In the Add New Item dialog box, choose the Office/SharePoint node.

  3. In the list of project templates, choose Visual Web Part, name it, and then choose the Add button.

    In Solution Explorer, your web part appears. After designing the web part in the Visual Web Developer designer, you'll test it on the site that you specify.