NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Validating Programmatically

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 [might 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

Validation Controls | Introduction to Validating User Input in Web Forms |