在异步回发更新面板禁用按钮 [英] Disable button in update panel on async postback

查看:155
本文介绍了在异步回发更新面板禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面上的各种按钮的asp多个更新面板。我想禁用这造成了更新面板回发的按钮,直到它完成。

I have multiple update panels with various asp buttons on a single page. I want to disable the buttons which caused the postback in update panel untill it completes.

有没有办法避免使用这种第三方的控制?通过JQuery的或任何其他方法?

Is there a way to avoid using a third party control for this? through JQuery or any other method ?

推荐答案

您可以做到这一点:

CS

//in pageload
//the request is not in postback or async mode
bt1.OnClientClick = "this.disabled = true; " + ClientScript.GetPostBackEventReference(bt1, null) + ";");

注意:您可以替换this.disabled =真,将有更好的处理禁用按钮,或许显示一个友好的信息,以及一个js函数

Note: you can replace "this.disabled = true" with a js function that will have better handling for disabling the button and maybe display a friendly message as well.

或者这样:

http://msdn.microsoft.com/en-us/library/ bb383989.aspx

爵士

Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(CheckStatus);
function CheckStatus(sender, arg)
{
   var postBackElement = arg.get_postBackElement();
   var prm = Sys.WebForms.PageRequestManager.getInstance();
   if (prm.get_isInAsyncPostBack() && postBackElement.id == "btn1") {
      arg.set_cancel(true);
      //display friendly message, etc
   }
}

注意:我修改了它,所以它会检查按钮的ID。替换BTN1

Note: I modified it so it checks for the button's id. Replace "btn1"

GOOD LUCK !!

Good luck!!

这篇关于在异步回发更新面板禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆