asp.net.ph

Skip Navigation Links

Validating Programmatically

ASP.NET Web Forms   Web Forms Server Controls   Web Forms Validation


The information that the validation controls use to check user input is available in properties of the control. For example, you set the limits for a range check using the MinimumValue and MaximumValue properties of the RangeValidator control.

Because this information is available in properties, you can change it at run time. A typical use is to set validation values based on information that a user has entered into another control, or to change the error message text based on run-time conditions. You can set any validation control property in code.

If you change validation control properties in code, the control will not be able to process user input automatically as part of normal page processing, because validation occurs before your code is called. You therefore must validate dynamically.

To validate programmatically

  1. Set the validation control properties that you want to change.
  2. Call the validation control’s Validate method.

The control will perform its check and if an error is detected, will set its IsValid property to false. When the page is returned to the user, error messages will be displayed as usual.

See Also

Types of Validation   Controlling Validation Message Display   Client-Side Validation   Data Entry Validation ( Client-Side )



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note