如何在更新面板中控制或停止部分回发 [英] How to Control or Stop Partial Post Back in Update Panel
问题描述
我一直在使用更新面板,所有我需要的是每当部分回发完成后,我需要检查一个条件,决定是否将该帖子转发回服务器
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
推荐答案
我将在一个例子中为您提供有关此事的解决方案。
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);
}
}
在这3个函数中,你可以控制你的部分帖子支持
并且这一行可以阻止你的回复,但我认为这只是在异步情况下
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();
这篇关于如何在更新面板中控制或停止部分回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!