Compartilhar via


What's New in Validation

ASP.NET validation controls provide a common way of tracking validation errors across a series of controls and presenting these errors to the user in a single place by using the ValidationSummary control.

Validation Groups

The ValidationGroup property is a new feature on many controls that allows you to associate individual controls with validation groups and then use multiple ValidationSummary controls to collect and report errors for those groups.

If a validation group is not specified, then validation functionality is equivalent to the validation functionality in ASP.NET version 1.0. If multiple validation groups are specified across multiple controls, then multiple validation summary controls must be displayed because a validation summary displays validation errors only for an individual group.

Controls that post back to the server and that currently have a CausesValidation property also introduce this ValidationGroup property, which determines the group of controls that should be validated when the control causes a postback. If no validation group is specified, the default group, which consists of all validators without an explicit group assignment, is validated.

Page Class Additions

The Page class now supports the GetValidators method, which retrieves validators that belong to the specified validation group.

The Page class also exposes an overload of the Validate method with a validation group as a parameter.

ASP.NET 1.0 Compatibility

Validation code from previous versions of ASP.NET will continue to work with the current release.

See Also

Tasks

How to: Control Validation Error Message Display for ASP.NET Server Controls

Reference

Validating User Input in ASP.NET Web Pages