ASP。NET AJAX vs jQuery ASP。NET MVC

时间:2022-04-07 05:25:51

Which one is better to use in ASP.NET MVC?

在ASP中使用哪个更好。净MVC吗?

10 个解决方案

#1


32  

Personally I prefer jQuery for the following reasons:-

我个人更喜欢jQuery,原因如下:

  1. The plug-in community is far more varied and attracts developers from a broad range of backgrounds (not just the MS stack). For MS-AJAX you're pretty much constrained to the clientside AJAX control toolkit for your UI widgets at the moment.
  2. 插件社区更加多样化,并且吸引了来自广泛背景的开发人员(不仅仅是MS stack)。对于MS-AJAX来说,目前您的UI小部件在客户端AJAX控制工具包中非常有限。
  3. I find the jQuery API far more applicable common clientside tasks than that offered by MS AJAX
  4. 我发现jQuery API比AJAX提供的更适用于常见的客户端任务。
  5. Given the lack of WebForms smoke and mirrors going on in MVC you sometimes need a firm control over the DOM to do certain things, the CSS selector engine offered by jQuery really helps you do this.
  6. 由于在MVC中缺乏WebForms烟雾和镜像,您有时需要对DOM进行严格的控制来完成某些事情,jQuery提供的CSS选择器引擎确实可以帮助您实现这一点。

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.

女士的AJAX提供您在MVC中,它可以为你做很多的给你一个快速的方法“AJAX化”形式和链接,但是就我而言增加了90 kb的javascript这样做并不值得当相当于调用jQuery(e。g美元。,美元。post、$(元素).load)相对容易使用。

#2


18  

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.

个人而言,尽管html助手支持ASP。NET Ajax,我发现jQuery Ajax结合jQuery forms插件是在ASP中完成Ajax表单发布的最好方式。净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

例如,在html产品列表页面上使用jquery调用,每个产品都有一个表单,允许将项目添加到购物篮中,只需一行jquery代码就可以“ajax化”页面上的所有表单

$(".productListItem form").ajaxForm({ target: '#extraInfoSection' });

combined with a simple 'IsAjaxRequest' property on a controller base class that checks the headers:

结合控制器基类上的一个简单的“IsAjaxRequest”属性来检查报头:

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.

你有一个即使javascript关闭也没有ASP的表单。Ajax涉及到网络。

#3


9  

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.

我建议你阅读Dave Ward的博客Encosia,它有一系列关于MS Ajax/ Update Panel和jQuery post机制的文章。Dave认为jQuery的性能非常优秀,因为它从服务器之间的传输中截取了大约100K。

#4


4  

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.

JQuery纯粹是客户端库。Asp。Net Ajax包括客户端和服务器端功能。哦,比较是不公平的。按照微软的计划,它们可能互相补充。

#5


2  

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.

ASP有一个变体。NET AJAX for MVC——与AjaxHelper和扩展一起使用。这与jQuery配合得很好。我有在同一页上使用这两个的例子;使用MVC AJAX更新基于单击按钮的DIV,使用jQuery获取同一页面上不同操作的JSON数据。标准的ASP。NET AJAX (UpdatePanels等)应该在WebForms中使用,而不是在MVC中使用。

#6


1  

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.

我想说的是微软支持JQuery,他们将在Visual Studio的新版本中支持JQuery。更多信息请访问http://live.visitmix.com/。ASP。NET AJAX和jQuery没有太多的重叠,所以您希望两者都使用。

#7


1  

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..

首先,记住ASP是很有用的。NET MVC不支持,或者更好,没有回发概念。

  1. asp.net ajax it's based on the post-back, server-side mechanism, it's mission it's to make more easy to integrate ajax features in a server-side mode
  2. net ajax它基于后端,服务器端机制,它的任务是使ajax功能在服务器端模式下集成更加容易
  3. jQuery, as other frameworks (eg Extjs) implements a pure client-side ajax
  4. jQuery作为其他框架(如Extjs)实现了一个纯客户端ajax

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:

在asp.net mvc和asp.net ajax中使用asp.net服务器控件仍然是可能的,但是asp.net mvc被认为是分离关注点(视图)和尽可能的保持样式的,所以考虑到这一点,最终的想法是:

  1. Using ASP.NET Web Forms ASP.NET AJAX it's the right choiche
  2. 使用ASP。净Web表单ASP。NET AJAX是正确的选择
  3. Using ASP.NET MVC it's better to try to go client, so jQuery (or others) is the better
  4. 使用ASP。最好尝试客户端,所以jQuery(或其他)更好

Sorry for my english

对不起,我的英语

#8


1  

Use ASP.NET AJAX with Web Forms and jQuery with ASP.NET MVC

使用ASP。NET AJAX使用Web表单,jQuery使用ASP。NET MVC

#9


1  

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.

另一种可能的选择是Ajax。净,http://www.ajaxpro.info/。我认为它比ASP好。AJAX WebForms净。它在MVC下也可以运行。

#10


1  

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.

首先,您可以使用其中任何一种,只要当您谈论Microsoft Ajax时,您只是指的是客户端库。您可以使用MS Ajax客户端库和大多数工具箱扩展器,而不需要任何服务器端控件。我使用web表单构建了一个相当大的应用程序,然后Microsoft Ajax将其转换为MVC/jquery。我发现在MS Ajax库中使用的功能越来越少。有如此多的插件可用,以至于它甚至使ajax工具包过时。

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.

如果你说MS Ajax使用的是更新面板等等,我会说不,你不能在MVC中使用它们。事实上,不要使用它们!更新面板是模拟ajax,页面仍然经过它的生命周期,几乎违背了使用ajax的目的。

#1


32  

Personally I prefer jQuery for the following reasons:-

我个人更喜欢jQuery,原因如下:

  1. The plug-in community is far more varied and attracts developers from a broad range of backgrounds (not just the MS stack). For MS-AJAX you're pretty much constrained to the clientside AJAX control toolkit for your UI widgets at the moment.
  2. 插件社区更加多样化,并且吸引了来自广泛背景的开发人员(不仅仅是MS stack)。对于MS-AJAX来说,目前您的UI小部件在客户端AJAX控制工具包中非常有限。
  3. I find the jQuery API far more applicable common clientside tasks than that offered by MS AJAX
  4. 我发现jQuery API比AJAX提供的更适用于常见的客户端任务。
  5. Given the lack of WebForms smoke and mirrors going on in MVC you sometimes need a firm control over the DOM to do certain things, the CSS selector engine offered by jQuery really helps you do this.
  6. 由于在MVC中缺乏WebForms烟雾和镜像,您有时需要对DOM进行严格的控制来完成某些事情,jQuery提供的CSS选择器引擎确实可以帮助您实现这一点。

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.

女士的AJAX提供您在MVC中,它可以为你做很多的给你一个快速的方法“AJAX化”形式和链接,但是就我而言增加了90 kb的javascript这样做并不值得当相当于调用jQuery(e。g美元。,美元。post、$(元素).load)相对容易使用。

#2


18  

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.

个人而言,尽管html助手支持ASP。NET Ajax,我发现jQuery Ajax结合jQuery forms插件是在ASP中完成Ajax表单发布的最好方式。净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

例如,在html产品列表页面上使用jquery调用,每个产品都有一个表单,允许将项目添加到购物篮中,只需一行jquery代码就可以“ajax化”页面上的所有表单

$(".productListItem form").ajaxForm({ target: '#extraInfoSection' });

combined with a simple 'IsAjaxRequest' property on a controller base class that checks the headers:

结合控制器基类上的一个简单的“IsAjaxRequest”属性来检查报头:

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.

你有一个即使javascript关闭也没有ASP的表单。Ajax涉及到网络。

#3


9  

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.

我建议你阅读Dave Ward的博客Encosia,它有一系列关于MS Ajax/ Update Panel和jQuery post机制的文章。Dave认为jQuery的性能非常优秀,因为它从服务器之间的传输中截取了大约100K。

#4


4  

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.

JQuery纯粹是客户端库。Asp。Net Ajax包括客户端和服务器端功能。哦,比较是不公平的。按照微软的计划,它们可能互相补充。

#5


2  

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.

ASP有一个变体。NET AJAX for MVC——与AjaxHelper和扩展一起使用。这与jQuery配合得很好。我有在同一页上使用这两个的例子;使用MVC AJAX更新基于单击按钮的DIV,使用jQuery获取同一页面上不同操作的JSON数据。标准的ASP。NET AJAX (UpdatePanels等)应该在WebForms中使用,而不是在MVC中使用。

#6


1  

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.

我想说的是微软支持JQuery,他们将在Visual Studio的新版本中支持JQuery。更多信息请访问http://live.visitmix.com/。ASP。NET AJAX和jQuery没有太多的重叠,所以您希望两者都使用。

#7


1  

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..

首先,记住ASP是很有用的。NET MVC不支持,或者更好,没有回发概念。

  1. asp.net ajax it's based on the post-back, server-side mechanism, it's mission it's to make more easy to integrate ajax features in a server-side mode
  2. net ajax它基于后端,服务器端机制,它的任务是使ajax功能在服务器端模式下集成更加容易
  3. jQuery, as other frameworks (eg Extjs) implements a pure client-side ajax
  4. jQuery作为其他框架(如Extjs)实现了一个纯客户端ajax

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:

在asp.net mvc和asp.net ajax中使用asp.net服务器控件仍然是可能的,但是asp.net mvc被认为是分离关注点(视图)和尽可能的保持样式的,所以考虑到这一点,最终的想法是:

  1. Using ASP.NET Web Forms ASP.NET AJAX it's the right choiche
  2. 使用ASP。净Web表单ASP。NET AJAX是正确的选择
  3. Using ASP.NET MVC it's better to try to go client, so jQuery (or others) is the better
  4. 使用ASP。最好尝试客户端,所以jQuery(或其他)更好

Sorry for my english

对不起,我的英语

#8


1  

Use ASP.NET AJAX with Web Forms and jQuery with ASP.NET MVC

使用ASP。NET AJAX使用Web表单,jQuery使用ASP。NET MVC

#9


1  

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.

另一种可能的选择是Ajax。净,http://www.ajaxpro.info/。我认为它比ASP好。AJAX WebForms净。它在MVC下也可以运行。

#10


1  

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.

首先,您可以使用其中任何一种,只要当您谈论Microsoft Ajax时,您只是指的是客户端库。您可以使用MS Ajax客户端库和大多数工具箱扩展器,而不需要任何服务器端控件。我使用web表单构建了一个相当大的应用程序,然后Microsoft Ajax将其转换为MVC/jquery。我发现在MS Ajax库中使用的功能越来越少。有如此多的插件可用,以至于它甚至使ajax工具包过时。

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.

如果你说MS Ajax使用的是更新面板等等,我会说不,你不能在MVC中使用它们。事实上,不要使用它们!更新面板是模拟ajax,页面仍然经过它的生命周期,几乎违背了使用ajax的目的。