O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

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

Validate User Input

Problem

You want to examine controls for invalid input before continuing.

Solution

Use one of the five validator controls included with ASP.NET.

Discussion

Web applications are frequently subject to input errors because all the information is entered on the client side. Unlike in Windows applications, you can’t rely on events such as KeyPress to check input as it is entered. The only way to remedy these problems is to add your own JavaScript code for this purpose (as described in recipe Use JavaScript to Handle Key Presses, Mouse Movements, and More) or use the validator controls.

The validator controls serve two purposes: they check control values for input errors, and they display messages describing these errors. In addition, ...

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