Featured On ...

asp.net

totalasp.co.uk

fuzzysoftware.com

devdex.com

123aspx.com

dotnetfreaks.com

411asp.net

and more ...

ASP.NET Validation Package Demo 5 - Customised validation summary

The following demo is identical to demo 2 except that the validation summary has been customised. Like demo 2, the dummy form is designed to collect basic user information from a subscriber. The form contains a series of validation rules as follows:

  • The name, street, town, and country cannot be left blank.
  • The date of birth is optional, but the person subscribing must be older than 18. The field accepts either a US date format (MM/DD/YYYY) or a format that could not be considered to be ambiguous.
  • The email address must be a valid email address and cannot be left blank.

The client-side code in this example has been explicitly disabled so that the form is allowed to send errors back to the server. If client-side code were enabled, it would block all errors as the submit button was pressed, forcing only valid entries to be sent to the server and consequently the validation summary would not show.

As you will see from viewing the code for this demo, the demo validation summary is called "Validator." This is because it is extending the Validator control itself (i.e. MadWidgets.Validation.Validator). While it is not required to do this, it makes sense to do so as it reduces code. If the validation summary didn't extend the Validator control, it would need to reference the instance of the Validator rather than just calling its inherited members. In addition, the Validator control would have to be placed on the page somewhere anyway as a custom control.

>> Show me the page code!

>> Show me the code for the demo validation summary!

>> Show me the code for the normal validation summary shipped with the product!




Name
Street
Town
Country
Date of birth
Email

© 2002 - 2008 Copyright, Disclaimer and Privacy Statement