Blog

Adventures with Ajax and ASP.Net

Due to my new job, where I’m developing a web based ASP.Net WYSIWYG editor, I’ve been playing with several Ajax components available in the jungle out there.

Until now, I found two with merit, and I’ll be using both at same time because I found that they complete each other.

The point is that there are two major approaches to Ajax in the .Net world, the first is the invocation of methods on the server side, the other is a control based design approach where you just want your controls to work close to the usual ASP.net way.

MagicAjax

Magic Ajax is an Ajax engine composed of one control, AjaxPanel, that behaves just like the Panel control. It happens that everything you insert inside that AjaxPanel becomes Ajax-enabled and instead of the usual postbacks you get Ajax calls. No doubt that it works, you can insert anything in there and it will work well, even if you have a current application and you only move the objects into a n AjaxPanel. Easy like that.

Of course you’re able to do some tricks like configure async and sync calls, per-control and per-panel, and disable that behaviour to a specific control. You can also put AjaxPanels inside each other that the component will update just the needed panels.

I must confess, when developing with the normal approaches, that this component impressed me. Better, its LGPL.

AJAX.Net

The famous control started to impress me by its new company, BorgWorX, with a ugly name and an even worst site…

Anyway, this component serves another approach, the one I’m using more in my WYSIWYG, where I can easily call server side code from Javascript. I thought that the calls would be something ugly with dumbass names… but no, it is actually pretty nice:

Server Side: class YourClassName { [Ajax.AjaxMethod()] string YourMethod (some params) { return ""; } }

Client Side: var result = YourClassName.YourMethod (params);

As simple as that. The component even enables you to use some .Net types from JavaScript, like ICollections and DataRow, using their converters.

Until now Ajax.Net is proving itself as a great help and I’ll get a commercial license for it, although I’m thinking of taking a good look at their code and study a possible merge between Ajax.Net and MagicAjax.

There’s one thing missing on my tests, that’s Mono, of course. I haven’t tested them in Mono, but I wish to. Anyway, if any of you guys know other good components or have some tips post a comment.

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

7 Responses to “Adventures with Ajax and ASP.Net”

  1. alfredo canas says:

    Well, I was wondering if magicajax could work on mono,
    so I decided to compile the source code project with monodevelop. To my surprise I did not get any compilation errors, and when the time came to deploy the library I got some errors complaining that
    the AjaxCallObject.js script was not found, so I just modified the Web.config file, and set the scriptPath tag to the path where the AjaxCallObject.js script was, and voila! it worked like a charm.
    The only thing that I noticed is that on firefox I don’t get the loading message, but anyway, try it out yourself!.

  2. I have used AjaxPro (Ajax.NET) on Mono. I found
    a couple of problems getting them to work well.

    More info here

  3. timh says:

    have you
    looked at the Atlas project as well? http://atlas.asp.net

  4. Joshua Allen says:

    Did you look at atlas (atlas.asp.net)?
    Also, Zeepe is worth a look,

  5. Bertrand says:

    Well, I may not be exactly unbiased on this one, but Atlas deals with both
    approaches.

  6. alexmipego says:

    Well, I didn’t pay too much attention to Atlas, thats true. It seems a good option too, yet I have to know if Atlas only works with .Net 2.0 and if it will run under
    mono…

  7. DotNetSpace says:

    I think MagicAjax is much more simpler to use
    than Microsoft Ajax framework. And it is much less invasive, only need to modify the web
    application:

    http://www.dotnetspace.com/articles/general-articles/simple-ajax-example-using-magicajax.html

    it is a good and simple example of code with MagicAjax

Leave a Reply

For spam filtering purposes, please copy the number 3357 to the field below: