How to Control or Stop Partial Post Back in Update Panel

拜拜、爱过 提交于 2019-12-11 03:29:25

问题


I have been using update panels , all i need is whenever a partial post back is done , i need to check for a condition which decides whether to proceed that post back to server or not

for now all i know is i can write the necessary code in

function pageLoad(sender, args) 
{
    if (args.get_isPartialLoad()) {
       // What should be done here to control the partial postback
     }    
}

i am trying to do the conventional "save confirmation before exit" in update panels with partial postback


回答1:


I will provide you a solution about that matter in 1 example.

There is a begin ,end and initialize events for the update panel partial post back and it attached as follow

function pageLoad(sender, arg) {
    if (!arg.get_isPartialLoad()) {
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(update_begin);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(update_end);
Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(ControlMyPostBack);
          }
        }

 function update_begin(sender, args) {
        }

 function update_end(sender, args) {
        } 

function ControlMyPostBack(sender, args)
       {
        if(condition)
           {
           //abort my partial post back
           args.set_cancel(true); 
           } 
       }

in these 3 functions, you can control your partial post backs and also this line can stop your post back but I think it's only in async case

Sys.WebForms.PageRequestManager.getInstance().abortPostBack();


来源:https://stackoverflow.com/questions/5803630/how-to-control-or-stop-partial-post-back-in-update-panel

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