__doPostBack重新加载整个页面,而不只是重新加载UpdatePanel [英] __doPostBack reloading entire page instead of just the UpdatePanel
问题描述
在我的JavaScript中,我有以下一行:
In my javascript, I have the following line:
__doPostBack('MyPanel', MyParam);
在后面的代码中,我使用MyParam查询数据库并将结果绑定到MyPanel updatepanel内的gridview. updatepanel的updatemode设置为有条件,在代码的回发部分中,我有MyPanel.Update();
In my code behind, I use MyParam to query a database and bind the result to a gridview that's inside the MyPanel updatepanel. The updatemode of the updatepanel is set to conditional and in the postback part of the code I have MyPanel.Update();
当我进行排序和分页时,updatepanel可以正常工作;仅刷新面板.但是,当我使用javascript触发updatepanel时,我在firebug中看到了显示整个页面正在刷新的流量.
The updatepanel works fine when I'm doing sorting and paging; only the panel is refreshed. However, when I trigger the updatepanel with my javascript, I see the traffic in firebug showing that the entire page is being refreshed.
有什么解决方案?
谢谢.
推荐答案
我的假设:您的更新面板位于命名容器内,因此其在客户端的ID与服务器端的ID略有不同.这意味着您将错误的__EVENTTARGET
参数传递给客户端side __doPostBack
函数,并且部分回发已满(表示不异步).
My assuption: your update panel is located inside the naming container, so its id in the client side will be a little bit different from the server side ID. This means you pass the wrong __EVENTTARGET
parameter to the client side __doPostBack
function and your partial postback became full(meaning not async).
因此将您的客户端代码更改为:
So changing your client code to:
__doPostBack('<%= MyPanel.ClientID %>', MyParam);
应该解决问题.
顺便说一句,您可以从服务器端获取第二个(代码中的MyParam
)参数:
BTW, you could get the second(MyParam
in your code) parameter from the server side:
var arg = Request.Params.Get("__EVENTARGUMENT");
这篇关于__doPostBack重新加载整个页面,而不只是重新加载UpdatePanel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!