如何使用jQuery和AJAX刷新ASP.NET ListView? [英] How do I refresh an ASP.NET ListView using jQuery and AJAX?

查看:105
本文介绍了如何使用jQuery和AJAX刷新ASP.NET ListView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面与一些ListViews,我希望用户能够排序和浏览。而不是每次回发和重新绑定整个页面,我想通过jQuery / AJAX有选择地为有问题的控件执行。我很乐意让客户端调用我的页面中的WebMethod - 我的问题是如何通过jQuery将返回的数据返回到ListView?



(注意:我不想使用UpdatePanel!)

解决方案

我不知道是否真的可以实现更新ListView没有回发,只是因为ListView控件的底层数据模型。



最好的选择是使用一个完整的AJAX解决方案来使用JavaScript模板引擎。我使用jTemplates和MS AJAX Library v4预览在我的博客上做了一个演示 - http://www.aaron-powell.com/blog.aspx?id=1209



但尽管有相当的信念,您可以使用UpdatePanel并使其有效,我也在这里查看: http ://www.aaron-powell.com/blog.aspx?id = 1195 。使用UpdatePanels时要记住的最大的事情是ViewState。如果您不需要在控件上保存ViewState,请确保已关闭。你可以通过这样做减少你的后期负载。还要清除空格将有所帮助。


I have a page with a number of ListViews that I want users to be able to sort and page through. Rather than postback and rebind the entire page each time, I would like to do it via jQuery/AJAX selectively for the control in question. I am comfortable making the client-side call to a WebMethod in my page - my question is how do I get the returned data back into the ListView via jQuery?

(Note: I don't want to use an UpdatePanel!)

解决方案

I'm not sure if it'll actually be achievable to update a ListView without a postback, just because of the underlying data model of the ListView control.

You're best option to having a complete AJAX solution would be to use a JavaScript templating engine. I've done a demo on my blog using jTemplates and the MS AJAX Library v4 preview - http://www.aaron-powell.com/blog.aspx?id=1209

But despite common belief you can use an UpdatePanel and have it efficient, I also looked at that here: http://www.aaron-powell.com/blog.aspx?id=1195. The biggest thing to keep in mind when using UpdatePanels is ViewState. If you don't need ViewState saved on a control make sure it's turned off. You can really reduce your post-load by doing that. Also removing whitespace will help.

这篇关于如何使用jQuery和AJAX刷新ASP.NET ListView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆