This article is intended for anyone who is looking for an easy-to-use AJAX web control.
Using the code
This control was intended to be as easy to use as it can be, and so it is.
protected void Page_Load(object sender, EventArgs e)
AJAX aj = new AJAX("myAJAX" , "AJAXCallbackHandler", this.AJAXCommandEventHandler, this.AJAXErrorOccuredEventHandler);
private void AJAXCommandEventHandler(object sender, AJAXCommandEventArgs e)
e.Response = "Response from the server";
private void AJAXErrorOccuredEventHandler(object sender, AJAXErrorEventArgs e)
Response.Write("Error occured in AJAX control - message: " + e.Message);
myAJAX.SendCommand("message", 10000); }
alert("Request was: " + resp.Request +
" and response from the server is " + resp.Response);
Points of interest
But, even with this functionality, I recommend you to group those callbacks into a bigger one rather than send many in a sequence. On the other side, if your callbacks are large, then the first option is better.
I've also done some fixes, including sending bad characters ('<', '>', '=', '?', '&', ....) in a callback. Now, you can send anything you like, it should work just fine. If it doesn't, please let me know!
And that's just it. Now, you can easily use AJAX callbacks in your application. The control was tested and worked fine under IE7, IE8, Firefox v3.0, and Opera v9.51 browsers. Please let me know if you experience any difficulties while using the control. And, I will also like to hear some improvements suggestions.