Add a Web Form
The contents of this section:
- What is a Web Form
- How to add a Web Form
1. Add a Web form to the project
Web Forms are an ASP. NET feature that you can use to create a user interface for your WEB application. Web Forms pages provide you with a powerful and straightforward programming model that uses your familiar rapid application development (RAD) technology to generate a complex WEB-based user interface.
For beginners, it's enough to know that adding new Web Form items to add content to a Web application is all that's needed.
On the Project "Partyinvites" (note not the Partyinvites solution), right-click, select Add-new item, pop up the Add New Item dialog box:
Figure 1 Adding a new item
Click the Add button to exit the dialog box and create a new item. You will see that Visual studio has added the Default.aspx file to the project in the Solution Explorer (Solution Explorer) and opened the file for editing. The initial contents of the file are shown in Listing 1-1.
Code Listing 1-1 The initial contents of the Default.aspx file
Essentially, a Web Forms file is an enhanced HTML file. The elements with <% and%> tags indicate that this is not a regular HTML file, the runat attribute in the head and form elements [this book translates the property into "attributes" and attribute to "features". This is also illustrated by the translator's note. This is covered later, and now just to emphasize that the form file is really HTML. In code listing 1-2, we have added some standard HTML elements to the Default.aspx file.
Code Listing 1-2 Adding standard HTML elements to the Default.aspx file
Here you add a h1 element and a P element, which contains some simple text. These are not special elements that are specifically for ASP. NET, but standard HTML elements.
Getting Started with ASP-the first ASP. NET application (2)