开发者

generate ajax postback for only one updatepannel in javascript

开发者 https://www.devze.com 2023-02-11 19:27 出处:网络
when I click a button the content inside my updatepannel changes. The id of the button is set as a trigger for the updatepannel, so that the othe开发者_JS百科r updatepannels are not affected.

when I click a button the content inside my updatepannel changes. The id of the button is set as a trigger for the updatepannel, so that the othe开发者_JS百科r updatepannels are not affected. How can I replace the buttonclick event with a page load event?

Is there a way to specify the pageload javasript event as a trigger for the updatepannel?


There's no way to register pageLoad() as a trigger, but you can call __doPostBack() in that function to force your UpdatePanel to refresh itself. However, that will cause an infinite loop if you're not careful, because pageLoad() is also called when partial postbacks complete.

One way around that problem is to set a flag before refreshing the panel, and persist that flag in the window object so it survives partial postbacks:

function pageLoad()
{
   if (!this.panelRefreshed) {
       this.panelRefreshed = true;
       __doPostBack("yourUpdatePanelClientID", "");
   }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消