Introduction
This is example of the use of simple AJAX with ASP.NET.It includes AJAX search like Google Suggest.
Background
As per new technology,the end user wants real time experience while surfing the websites.As Microsoft provides some AJAX controls with ASP.NET,But it is necessary to install AJAX control toolkit and DLL on the server.So why do such installations? This is the example of the AJAX with simple JAVASCRIPT and XMLHTTPREQUSET to implement such functionality.I have used it with ASP.NET 2.0. So we can use it for multiple use like data validation(username checking),password strength cheking,Star Rating and many more.... as per your use.
Using the code
This example has two aspx files and only on js file,that is for ajax implementation.You need to do only one thing and you example is ready to use.Just change the connection string in the process.aspx page.I have given some code snippet below:
var me = this;
this.mRequest = null;
this.mhTarget = hTarget;
sURL=sURL+"?search="+txtVal+"&Id="+txtId+"&X="+event.screenX;
if( window.XMLHttpRequest )
{
this.mRequest = new XMLHttpRequest();
}
else
if( window.ActiveXObject )
{
this.mRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
if( this.mRequest )
{
this.mRequest.open( 'GET', sURL , true );
this.mRequest.onreadystatechange = function(){ fAJAXStateChange(me); };
this.mRequest.send( null );
}
function fAJAXStateChange( hAJAXRequest )
{
if( hAJAXRequest && hAJAXRequest.mRequest && hAJAXRequest.mRequest.readyState == 4 )
{
var s = hAJAXRequest.mRequest.responseText;
hAJAXRequest.mhTarget.innerHTML = s;
}
}
Points of Interest
I am glad to receive any modifications or new Ideas with using this code.
History
It is compatible with ASP.NET 1.1 & ASP.NET 2.0/C#