__doPostBack reloading entire page instead of just the UpdatePanel

久未见 提交于 2019-12-10 17:33:08

问题


In my javascript, I have the following line:

__doPostBack('MyPanel', MyParam);

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();

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.

What's the solution?

Thanks.


回答1:


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);

should solve the problem.

BTW, you could get the second(MyParam in your code) parameter from the server side:

var arg = Request.Params.Get("__EVENTARGUMENT");


来源:https://stackoverflow.com/questions/4959591/dopostback-reloading-entire-page-instead-of-just-the-updatepanel

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