O'Reilly logo

C# Primer: A Practical Approach by Stanley B. Lippman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.16. Adding Validators to a Control

If you look back at Figure 7.5, you'll see that we must have two input fields to set up an appointment for the user: the user's name and the date of the appointment. A phone number is optional. If submitted, however, we want to confirm whether it is a seven-digit or a ten-digit U.S. phone number. If the user does not select a time, we'll assume that the default time on display is intended. If the user does not select a trainer, we'll make that assignment ourselves.

Web Forms provides the following validation controls (an icon for each is available in the Web Forms section of the Toolbox window):

  • RequiredFieldValidator, which prevents an entry from being skipped. For example, we will attach this to the TextBox ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required