ASP.NET AJAX server-side validation made easy

Thursday, October 4, 2007

The Validation Guidance Bundle is a new set of extensions to the Ajax Control Toolkit introducing AJAX enabled validators.  This is great for situations where a user is entering data unto a web form that needs to be validated against the server.  I have a current situation where I need to make sure that a posting’s chosen Url is unique.  With this bundle, I can simply point it to the CustomValidator control which is already tied to a server-side validation method and AJAX will take care of the rest.  When the user tabs off of the txtUrl control, it will go back the server and validate the input in your custom method.  This is also valid for when users are choosing a login name or when you need to do any validation that you don’t want to put on the client.

It also works directly with the EntLib Validation Block through a set of property proxies.

One minor gotcha that I ran into is that the assembly references a specific version of the AjaxControlToolkit assembly.  If you are using the latest build of the AjaxControlToolkit, you’ll get some ugly errors about not being able to load the correct assembly.  I finally noticed that in the prerequisites for the validation bundle, it is stated that you need release version 10618 of the toolkit (as oppose to the latest 10920 version).  Some more uses are described below:

  • Improving UI responsiveness while reusing entity business validation logic across screens when performing validations such as:

    •  Length of Employee name.

    •  Employee’s email.

    •  Order number is unique.

    •  Order is complete.

  • Improving UI responsiveness for applications utilizing Server-Side ASP.NET validators.

  • Determining what type of validation to use for improving responsiveness and security.

Leave a Reply