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 writ开发者_C百科e 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
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();
精彩评论