Inserting a Validation Control
Inserting a validation control is no different from inserting any other control. If you are using Visual Studio .NET, you can simply drag the appropriate control onto your page's layout. Otherwise, simply insert the appropriate control within the HTML where you would like the validation's message to appear if the input is not valid. The following example demonstrates how to require a user to enter his or her name.
Perhaps the most common form of validation is simply to require that fields be filled in. The RequiredFieldValidator control does just this. Listing 8.1 shows the relevant code to make a text box entry required (that is, to ensure that the user enters some value).
Listing 8.1. Adding required validation ...
Get ASP.NET by Example 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.