Montag, Oktober 03, 2005

Using AJAX enabled controls in ASP.NET Forms

The use of web forms is for many web applications the most important functionality. They rely very much on it because it was implemented by all old browsers they also the modern ones still provide this functionality.

Using AJAX functionalities in your web applications doesn't mean that everything needs to be re-implemented. With the AJAX functionality these applications can easily be extended with controls using asynchronous functionalities in the background without breaking up the existing applications structure:

  • Validate values immediately on the server after the user exits the field without reloading the form.
  • Help the user to find the right value by extending a field with a specific lookup function.
  • Show or hide a field, depending of already entered values.
  • Fill fields in the form, depending of already entered values.
  • Fill the OPTIONS of HTML SELECT elements depending of already entered values.

Common to these scenarios is that a pure client-side implementation is often hard to do or impossible because some data is required and this data is not available on the client directly. On the server in contrary, the information is available and is in classical Web Forms used to validate the input of the user before accepting and executing the functionality.

If you integrate AJAX controls into your existing web applications it is possible to make your forms more responsive and give faster feedback and help to the user. The processing of the Web Form can stay as it is by submitting the data of the form to the server and reloading or redirecting the page after the server side processing is done.

On the sample website to this Blog at you can find some samples that show the usage of AJAX based functionality in regular Web Form applications:

Validator Demo shows how to use a server-side DNS lookup to check if the host part of an email address is known on the web without reloading the whole form.

Bible Reader here you can see beside other things how to populate OPTIONS of a HTML SELECT element dependent of other values without reloading the whole form.


Anonym hat gesagt…

localhost ?

MatHertel hat gesagt…

I fixed the links asap.

Anonym hat gesagt…

sorry for comment here and not y the correspont post.
In library "ajax.js", what is the max size that support responseXML for a string?
the xmlhttrequest object not support more than 467 characters?


MatHertel hat gesagt…

I verified that right now using the following script:

var s='X';
for (i=0; i < 22; i++)

and the Web Service:

public int HelloStringLength(string s) {
return (s.Length);

Up to 2^21 chars everything works out of the box.
beyond that size you have to set the parameter in web.config to something higher. Sample:

<httpRuntime maxRequestLength="10000" />

If you have problems, I think that they are not caused by limitations on responseXML.
Tested with IE and Firefox.
send me a sam,ple and I will have a look.