简体   繁体   English

更新面板或Ajax调用

[英]Update Panel or Ajax calls

I'm doing one app which requires AJAX call on almost every user interaction possible, I started writing JS functions, webservices etc. to handle all of that(still long way to go from here). 我正在做一个应用程序,几乎所有可能的用户交互都需要AJAX调用,我开始编写JS函数,Web服务等来处理所有这些(距离这里还有很长的路要走)。

Now I am wondering If I made a mistake maybe I should put whole page in update panel because I really hate writting JS. 现在我想知道如果我犯了一个错误,也许我应该将整个页面放在更新面板中,因为我真的很讨厌写JS。 Is there some drawback to use it instead of custom written ajax calls to web service and js functions, and is it better to use more update panels or one big? 使用它而不是对Web服务和js函数进行自定义的Ajax调用是否有一些缺点,并且使用更多的更新面板还是更大的更新面板更好?

The biggest advantage to writing your own is performance. 编写自己的书最大的好处就是性能。 Writing your own JS and webservices is going to be much, much faster. 编写自己的JS和Web服务的速度将会快得多。

Microsoft's AJAX UpdatePanels actually re-render the entire page, but then only replace the sections of data that you surrounded with the UpdatePanel tags. Microsoft的AJAX UpdatePanels实际上重新呈现了整个页面,但随后仅用UpdatePanel标记替换了您所包围的数据部分。 When you write your own, you can fully control what happens and when. 编写自己的书时,您可以完全控制发生的情况和时间。 And if you ever migrate or port your code away from ASP.NET, it's going to be much more reusable. 而且,如果您曾经从ASP.NET迁移或移植代码,它将具有更高的可重用性。

Update panel is easier, however it negates almost all the benefits of AJAX because it needs to run through the whole page lifecycle for each postback and loads pretty much the entire page. 更新面板更容易,但是它几乎抵消了AJAX的所有好处,因为它需要贯穿每个回发的整个页面生命周期,并加载几乎整个页面。

Performance-wise manual ajax calls is going to be better. 性能方面的手动ajax调用会更好。

Another drawback to using update panels is that it is a part of the ASP.NET Ajax Toolkit. 使用更新面板的另一个缺点是它是ASP.NET Ajax Toolkit的一部分。 The toolkit has been deprecated and is no longer supported. 该工具包已被弃用,不再受支持。

See this post for more info: ASP.NET Ajax vs. JQuery for web service calls 有关更多信息,请参见此帖子: Web服务调用的ASP.NET Ajax与JQuery

The post also contains an interesting blog post about it. 该帖子还包含一个有趣的博客文章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM