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", "");
}
}
精彩评论