Validation Controls

ASP.NET offers a full suite of validation controls, which can be used to easily validate user input in other ASP.NET controls. These include the RequiredFieldValidator, CompareValidator, RangeValidator, RegularExpressionValidator, CustomValidator, and ValidationSummary controls. This section talks about and shows how to use the RequiredFieldValidator and the RegularExpressionValidator. Although these are covered in depth in Chapter 12, I’ll talk about them here in the context of ASP.NET server controls. Examples showing how to use the others can be found on www.UsingASP.net.

Imagine that you have a TextBox control in your code as follows:

<asp:TextBox id=”TextBox1” runat=”server” /> 

If you have a required field and you ...

Get Special Edition Using® Microsoft® ASP.NET 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.