Export (0) Print
Expand All

Adding Web Forms Pages to a Web Project

After you have started a Web project, you can create new Web Forms pages and add existing Web Forms pages to the project. For instructions on creating an ASP.NET Web application, see Creating Web Projects.

Note   You can add a Web Forms page to an existing Web project or add a page from another project. However, all pages in a single project must use the same programming language. For example, you cannot add a Visual C# Web Forms page to a Visual Basic project or vice versa.

Visual Studio enables shared working arrangements. A development team could split the development of new Web Forms pages between members, write code individually in separate projects and, using source control, add them to a single project. For more information on source control, see Source Control Basics.

When you create a Web Forms page, Visual Studio performs the necessary operations to include this file in your project. For an overview, see Web Forms Pages and Projects in Visual Studio.

To create a Web Forms page

  1. In Solution Explorer, right-click the project name, click Add, then click Add Web Form.

    The Add New Item dialog box is displayed.

  2. In the Categories pane, verify the Web Project Items node is highlighted and select Web Form in the Templates pane.
  3. Supply a name for the form in the Name box at the bottom, then click Open.

    The new Web Forms page is created and displayed in the Web Forms Designer. If you want to give your form a different name, rename it in Solution Explorer. For an overview of managing Web Form pages, see Creating and Managing Web Forms Pages.

To add an existing Web Forms page to a project

  1. In Solution Explorer, right-click the project name and click Add, then click Add Existing Item.

    The Add Existing Item dialog box is displayed.

  2. Navigate to the directory containing the Web Forms page, select the page, and click Open.
  3. If the existing file does not have a code-behind class file (.aspx.vb or .aspx.cs file), Visual Studio prompts you to create one. Typically, if the file page you are adding is a single-file Web Forms page, you do not need to create a code-behind class file, and you can click No.

    The Web Forms page is added to the project and opened in Design view.

    Note   When you add an existing file, the file is copied to your project. (The file is not simply added by reference). If you change the file in your project, the original file is left unchanged.

You can also rename a page by renaming it in Solution Explorer.

To change the name of a Web Forms page in a project using Solution Explorer

  1. In Solution Explorer, right-click the file you want to change and click Rename.
  2. Type the new file name you want, then press ENTER.

See Also

Web Forms Pages and Projects in Visual Studio | Creating and Managing Web Forms Pages

Show:
© 2015 Microsoft