Web Sites Created Using ASP.NET
ASP seemed great a few years ago, but now ASP.NET provides a simpler,
faster, more powerful way to create Web applications. Instead of using a
scripting language, you may now create real, fully compiled applications.
You can write these applications using any of the .NET-compliant languages
available, and you can use the great tools provided by Visual Studio .NET
to do your work. Any developer can now create full-featured, powerful Web
applications.
Creating a New ASP.NET Application
Enough talking about it梙ow about actually creating a simple Web
application? To get started, you'll create a project with a Web Form that
allows users to input first and last names. After entering the data into
these two text controls on the Web page, a user clicks a button and sees
the entered information appear in a label below the button.
Figure 5.1 shows the sample Web Form you will create.
Figure 5.1. This simple page allows you to enter values, and clicking the
button runs code to process those values.
Creating the Login Form
To get started, you'll need to create a new Web Application project in
Visual Studio .NET:
Start Visual Studio .NET and select the File, New, Project menu item.
In the New Project dialog box, select Visual Basic Projects in the Project
Types pane.
In the Templates pane, select ASP.NET Web Application.
In the Location text box, enter http://www.localhost/Jumpstart/Northwind as
the location for the project.
Click OK to allow Visual Studio .NET to create the virtual root, add the
project template, and prepare for you to begin working on the project. This
may take a few moments.
By default, Visual Studio .NET creates a page named WebForm1.aspx. Although
you could develop your application using this page, you'll generally want
to rename the page, the code file, and the programming class contained
within the code file. It's easier to simply delete the whole page and
create a new one, using your own name.
Select WebForm1.aspx in the Solution Explorer window (most likely, the
Solution Explorer window will appear in the upper-right corner of the
Visual Studio .NET environment), right-click, and select Delete from the
context menu.
Select the Project, Add Web Form menu item.
Set the name of this new page to Login.aspx and then click Open to add the
page.
Use the View, Toolbox menu item to ensure that the Toolbox window is
visible. Then add controls and set properties as shown here.
Control Type Property Value
Label ID Label1
Text First Name
TextBox ID txtFirst
Label ID Label2
Text Last Name
TextBox ID txtLast
Button ID btnLogin
Text Login
Label ID lblName
BorderStyle Inset
Text (Delete the text, so you see just the label's name.)
To view the layout information you've created, choose the View, HTML Source
menu item (or click the HTML tab at the bottom of the designer window).
You'll see HTML but no programming code梩hat goes into a separate location.
Select the View, Design menu item to get back to the normal design view.
Select File, Save All to save your project.
Running the Login Form
At this point, you can run this application and see the Web Form appear in
your browser. Although this page does not have any functionality yet, this
exercise is a good test to make sure everything is running up to this
point. Here are the steps to follow:
Select Login.aspx in the Solution Explorer window.
Right-click and select Set as Start Page from the context menu.
Press F5 to run this sample application.
TIP
If you have trouble running the application, refer back to the instructions
in Chapter 1, "Getting Started with the Sample Application." You may need
to configure your project to allow debugging.
You should now see the Web Form displayed in your browser, and you can
enter data into the two text fields. If you click the button, nothing will
happen because you have not told it to do anything yet. You need to add
some code in order for the button to have any effect.
TIP
While your page is open in the browser window, right-click and select View
Source from the context menu. Although there will be a bunch of stuff in
the page that you didn't put there (ASP.NET adds some useful