30.07.2013 Views

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 20 ASP .<strong>NET</strong>, Web Forms and Web Controls 969<br />

88 <br />

89 images/thailand.png<br />

90 <br />

91 http://www.odci.gov/cia/publications/factbook/geos/th.html<br />

92 <br />

93 Thailand Information<br />

94 1<br />

95 <br />

96<br />

97 <br />

98 images/unitedstates.png<br />

99 <br />

100 http://www.odci.gov/cia/publications/factbook/geos/us.html<br />

101 <br />

102 United States Information<br />

103 1<br />

104 <br />

105 <br />

Fig. 20.20 AdvertisementFile used in AdRota<strong>to</strong>r example (part 3 of 3).<br />

20.5.3 Validation Controls<br />

This section introduces a different type of Web control, called a validation control (or valida<strong>to</strong>r),<br />

which detremines whether the data in another Web control are in the proper format.<br />

For example, valida<strong>to</strong>rs could determine whether a user has provided information in a required<br />

field or whether a ZIP-code field contains exactly five digits. Valida<strong>to</strong>rs provide a<br />

mechanism for validating user input on the client. When the HTML for our page is created,<br />

the valida<strong>to</strong>r is converted in<strong>to</strong> ECMAScript 3 that performs the validation. ECMAScript is<br />

a scripting language that enhances the functionality and appearance of Web pages. ECMA-<br />

Script is typically executed on the client. <strong>How</strong>ever, if the client does not support scripting<br />

or scripting is disabled, validation is performed on the server.<br />

The example in this section prompts the user <strong>to</strong> input a phone number, in the form 555–<br />

4567. After the user enters a number, valida<strong>to</strong>rs ensure that the phone-number field is filled<br />

and that the number is in the correct format before the program sends the number <strong>to</strong> the<br />

Web server. Once the phone number is submitted, the Web Server responds by sending an<br />

HTML page containing all possible letter combinations that represent the phone number.<br />

The letters used for each digit are the letters found on a phone’s key pad. For instance, the<br />

5-but<strong>to</strong>n displays the letters j, k and l. For the position in the phone number where there is<br />

a 5, we can substitute one of these three letters. Businesses often use this technique <strong>to</strong> make<br />

their phone numbers easy <strong>to</strong> remember. Figure 20.21 presents the ASPX file.<br />

The HTML page sent <strong>to</strong> the client browser accepts a phone number in the form 555–<br />

4567 and then lists all the possible words that can be generated from both the first three<br />

digits and the last four digits. This example uses a RegularExpressionValida<strong>to</strong>r<br />

3. ECMAScript (commonly known as JavaScript) is a scripting standard created by the ECMA (European<br />

Computer Manufacturer’s Association). Both Netscape’s JavaScript and Microsoft’s<br />

JScript implement the ECMAScript standard, but each provides additional features beyond the<br />

specification. For information on the current ECMAScript standard, visit www.ecma.ch/<br />

stand/ecma-262.htm.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!