Using Synchronous PageMethod Custom Validator Control and jQuery calls of ASP.NET AJAX’s PageMethods

Using Synchronous PageMethod Custom Validator Control and jQuery calls of ASP.NET AJAX’s PageMethods.

Introduction

This is success story of using Synchronous PageMethod Custom Validator Control in enterprise application development. Instead of using standard Synchronous JavaScript call we’ve expanded it to using jQuery.

In general Synchronous PageMethod Custom Validator allows to call PageMethods to validate client-side input, and block postbacks if there is an error.

Background

The problem we faced was that we needed to validate large, heavy-wight custom web-form. It also needed to validate separate items and create custom script for each of them. The solution should be integrated into enterprise software that is in production.

The enterprise application we’ve used this control is business process automation software that works in heavy industry manufacturing.

Area of Usage

Synchronous PageMethod Custom Validator can be added directly to any AJAX-enabled website project. We’ve added it to a separate control library project in order to easily put it into toolbox without depending on a compiled version of application.

Originally Synchronous PageMethod Custom Validator Contol was based on:
Using PageMethods server-side validators on the client-side. The problem there was that the validator was asynchronous, and therefore was very difficult to use in a situation where it was necessary to block a postback if there are any validation errors.
Synchronous JavaScript call using Scriptable XML Webservice (S-AJAX) shows how to consume a Microsoft AJAX web service (System.Web.Script.Services.ScriptService) to call synchronously at the client side using the XMLHttpRequest object and JavaScript.

Also we needed to make this solutions cross-browser and make it easy to develop and maintanmece. We decided to use jQuery to call a PageMethod without using the ScriptManager. This is good solution for lightweight client-side communication instead of full ASMX web services.

Conclusion

SoftElegance has successfully used Synchronous PageMethod Custom Validator Control with jQuery calls of ASP.NET AJAX PageMethods to instant validation for web-forms in enterprise class software development project.

Leave a Reply

Your email address will not be published. Required fields are marked *