O'Reilly logo

Programming Visual Basic .NET by Dave Grundgeiger

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

Adding Validation

Validating user input is a common requirement of any application that relies on the user to provide data. The ASP.NET framework provides tools to make input validation easy. ASP.NET supports validation by providing server controls that handle the validation process. Each server control placed on a form is responsible for validating the value in some other control on the form. The validation process occurs both on the client (if the browser is capable) and on the server, or just on the server (if the browser can’t handle it). Validation occurs on the server, even if it occurs on the client, to prohibit a hostile client from submitting invalid data.

The server controls that relate to validation are:

CompareValidator

Compares the value in a control with either a constant value or the value in another control. The developer chooses the comparison to be performed (equal, less than, greater than, etc.). The validation succeeds if the comparison is True.

CustomValidator

Allows the application to perform validation logic that isn’t provided by the standard comparison controls.

RangeValidator

Compares the value in a control to a given range. The validation succeeds if the value is within the range.

RegularExpressionValidator

Compares the value in a control to a given regular expression. The validation succeeds if the value is matched by the regular expression.

RequiredFieldValidator

Checks that a value has been entered into a control. The validation succeeds if the value ...

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