How to Create a New Asp.Net Web Application
ASP.NET Web application projects are commonly confused with ASP.NET website projects. Microsoft says that there are benefits to using either type of project. The project type that you select will depend upon your programming needs. Website projects, for example, require you to place classes inside an "App_Code" folder, while Web application projects do not. Regardless of the project type that you choose, the method of initially setting them up will be the same. To create a new ASP.NET Web application project, you will need a copy of Microsoft Visual Studio.
Instructions
-
Instructions
-
1
Open Visual Studio and select "File ," "New Project," "ASP.NET Web Application" and "OK." This will create a new Web application project named "WebApplication1." A default Web page named "Default.aspx" will appear in the "Solution Explorer" on the right of the screen. The "Solution Explorer" contains all the files in your Web application.
-
2
Double-click the "Default.aspx" file to open it in the editor. Visual Studio will create a skeleton ASP.NET form in the editor that contains an ASP.NET form. Unlike ordinary HTML pages, ASP.NET pages can contain only one form. You will place all controls within this form.
-
-
3
Add the following code below the "<form>" tag:
<h1>My Test Application</h1>
<asp:Button ID="MyButton" runat="server" Text="MyButton" />
<asp:Label ID="MyLabel" runat="server" Text="MyLabel"></asp:Label>This will create an ASP.NET button and an ASP.NET label. Each control has a runat="server" parameter. All ASP.NET server controls must have this parameter. Visual Studio comes with a variety of HTML, data and navigation controls. You can add these controls anywhere on the page.
-
4
Double-click the "Design" button at the bottom of the screen. This will open the designer window. You can develop your application by alternating between the design view and the source code view. Use the design view when you want to drag and drop controls from the toolbox to the page. You can also see what your page will look like in a browser while you are in design view. Use the source code view to update the code manually.
-
5
Press "F5" to run your application. Visual Studio will compile it and display the Web page in your browser.
-
1
Tips & Warnings
To add additional items to your project, right-click the project name located at the top of the Solution Explorer. This will allow you to add JavaScript, CSS and other file types to the Web application. When learning to create new ASP.NET Web applications, use the right-click function extensively. You can discover many useful Visual Studio commands by right-clicking different elements and controls. See the Resources section for links to additional ASP.NET training resources.
References
Resources
- Photo Credit the programmer and a computer image by Andrey Andreev from Fotolia.com