Using the RequiredFieldValidator
Control
The RequiredFieldValidator
control enables you to require a user to enter a value into a form field before submitting the form. You must set two important properties when using the RequiredFieldValidator
control:
• ControlToValidate
—
The ID of the form field validated.
• Text
—
The error message displayed when validation fails.
The page in Listing 3.7 illustrates how you can use the RequiredFieldValidator
control to require a user to enter both a first and last name (see Figure 3.5).
Figure 3.5. Requiring a user to enter form field values.
Listing 3.7. ShowRequiredFieldValidator.aspx
By default, the ...
Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.