ASP.NET: replacing UpdatePanel with Jquery?

会有一股神秘感。 提交于 2019-12-23 02:53:21

问题


does anyone know if its possible to replace the updatepanel in asp.net ajax toolkit with some kind of jquery?

DOes anyone have any detailed instructions?

Basically we use the update panel so that when we do postbacks that the screen doesn't actually do a full refresh .. just the values ..

I am using jquery for a lot of other stuff and would love to know if there is some way to do this or even if a jquery plugin exists that lets you do it.

I am a bit unsure but would this mean i have to rename all my methods to static and decorate with the webmethod attribute?

If this is the case, it maybe a lot of work :-)

And of course how would Page_Load execute if it was a static webmethod?

Any tips or advice really appreciated


回答1:


I'm not sure how it would work with your code, but $.ajax() in jQuery would be able to replace your ajax function. Check it out here: http://api.jquery.com/jQuery.ajax/

The problem you may run into with this is parsing the data that comes back, with I bet is the main functionality of the updatePanel call. With jQuery, you input the url to call, any data you want to send, and the callback(s) to handle the response:

$.ajax({
  url: 'ajax/test.html',
  success: function(data) {
    $('.result').html(data);
    alert('Load was performed.');
  }
});

Going further, break this question up with the data being sent, and the actual objects on in your code that need to be updated. It's hard to help without being able to see any code.



来源:https://stackoverflow.com/questions/4210145/asp-net-replacing-updatepanel-with-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!