Microsoft Visual Basic 2010 Step by Step eBook

(Tina Meador) #1

Chapter 20 Creating Web Sites and Web Pages by Using Visual Web Developer and ASP .NET 509


Validating Input Fields on a Web Page
Although this Web page is useful, it runs into problems if the user forgets to enter
a principal amount or an interest rate or specifies data in the wrong format. To make
Web sites like this more robust, I usually add one or more validator controls that
force users to enter input in the proper format. The validator controls are located on
the Validation tab of the Visual Web Developer Toolbox and include controls that
require data entry in a field (RequiredFieldValidator), require entry in the proper range
(RangeValidator), and so on. For information on the validator controls, search the Visual
Studio Help documentation. They are straightforward to use.

Customizing the Web Site Template


Now the fun begins! Only very simple Web sites consist of just one Web page. Using Visual
Web Developer, you can expand your Web site quickly to include additional information and
resources, including HTML pages, XML pages, text files, database records, Web services, login
sessions, site maps, and more. If you want to add a Web page, you have three options:
n You can create a new Web page by using the HTML Page template or the Web Form
template. You select these templates by using the Add New Item command on the
Website menu. After you create the page, you add text and objects to the page by
using the Web Page Designer.
n You can add a Web page that you have already created by using the Add Existing
Item command on the Web site menu, and then customize the page in the Web Page
Designer. You use this method if you want to include one or more Web pages that you
have already created in a tool such as Expression Web. (If possible, add pages that don’t
rely on external style sheets and resources, or you’ll need to add those items to the
project as well .)
n You can use an existing Web page that is part of the Web site template that you are
using. For example, in the Web site template that you have open now, there is an About
Web page and various Login Web pages that you can customize and use quickly.
In the following exercise, you’ll display the About Web page supplied by the template that you
are using, and you will customize it with some information about how the car loan calculator
application works.

Customize the About .aspx Web page


  1. Display Solution Explorer, click the About .aspx file, and click the View Designer button.


Visual Web Designer displays About .aspx in the Designer, and it displays a line of
placeholder text (“Put content here .”).
Free download pdf