Reputation: 2894
Which one is better to use in ASP.NET MVC?
Upvotes: 33
Views: 8911
Reputation:
First of all, you could use either, as long as when you are talking about Microsoft Ajax, you are only referring to the client library. You can use the MS Ajax client library and most of the toolkit extenders without any server side controls. I have built a pretty big application using web forms and Microsoft Ajax then converted it to MVC/jquery. I found that I was using less and less of the features in the MS Ajax library. There is so much available with plugins, that its making even the ajax toolkit obsolete.
If you are talking about MS Ajax using update panels etc, then I would say no, you can't use them in MVC. In fact, don't use them at all! update panels are simulated ajax, the page still goes through its lifecylce almost defeating the purpose of using ajax.
Upvotes: 1
Reputation: 11624
Another alternative you probably could look at is Ajax.NET, http://www.ajaxpro.info/. I reckon it's better than ASP.NET AJAX for WebForms. It's runnable under MVC as well.
Upvotes: 1
Reputation: 8755
Personally I prefer jQuery for the following reasons:-
In terms of what MS AJAX offers you in MVC, it can do a lot for you in terms of giving you a quick way to "AJAXify" forms and links, but as far as I'm concerned adding 90kb worth of javascript to do that isn't really worth it when the equivalent calls in jQuery (e.g $.get, $.post, $(element).load) are relatively easy to use.
Upvotes: 34
Reputation: 10046
Instead of making a recommendation I suggest you read Dave Ward's blog Encosia that has a series of posts on MS Ajax/ Update Panel vs. jQuery post mechanism. Dave maintains that the performance of jQuery is vastly superior as it cuts out approximately 100K from the transmission to and from the server.
Upvotes: 9
Reputation: 1885
Use ASP.NET AJAX with Web Forms and jQuery with ASP.NET MVC
Upvotes: 1
Reputation: 1948
First of all, it could be useful to take in mind that ASP.NET MVC doesn't support, or better, doesn't has the postback concept..
It's still possible to use asp.net server controls in asp.net mvc, asp.net ajax it's one of them, but asp.net mvc it's made, it was thought, to separate concerns (views) and to be REST styled as close as possible, so taking this in mind the final thought would be:
Sorry for my english
Upvotes: 1
Reputation: 26849
Personally, despite the HtmlHelper support for ASP.NET Ajax, I find jQuery ajax in conjunction with the JQuery forms plugin to be the nicest way to do ajax form posts in ASP.NET MVC.
e.g. with a jquery call on an html product list page with a form for each product allowing the item to be added to a basket, a single line of jquery code can 'ajaxify' all the forms on the page
$(".productListItem form").ajaxForm({ target: '#extraInfoSection' });
combined with a simple 'IsAjaxRequest' property on a controller base class that checks the headers:
Request.Headers["X-Requested-With"] == "XMLHttpRequest"
and some logic in the Controller to return the correct response type:
return IsAjaxRequest ? (ActionResult) View("BasketPartial", basket) : new RedirectBackToReferrerActionResult();
you have a form that works even with javascript turned off and no ASP.NET Ajax involved.
Upvotes: 18
Reputation: 532465
There is a variant of ASP.NET AJAX for MVC -- used with the AjaxHelper and extensions. This works well in concert with jQuery. I have instances where I use both on the same page; using MVC AJAX to update a DIV based clicking a button and using jQuery to get JSON data for a different operation on the same page. Standard ASP.NET AJAX (UpdatePanels, etc.) should be used in the WebForms world, not in MVC.
Upvotes: 2
Reputation: 960
JQuery is purely client side library. Asp.Net Ajax includes both client side and server side functionalities. IMHO, comparison ain't really fair. They might complement each other going by Microsoft's plans.
Upvotes: 5
Reputation: 4745
I would like to mention that Microsoft supports JQuery, and they will make support for it in upcoming versions of Visual Studio. For more information please visit http://live.visitmix.com/. ASP.NET AJAX and jQuery does not overlap much, so you would like to use both.
Upvotes: 1