【问题标题】:Is there a way to disable UpdateProgress for certain async postbacks?有没有办法为某些异步回发禁用 UpdateProgress?
【发布时间】:2011-09-12 01:07:55
【问题描述】:

我有一个 UpdateProgress 控件,它显示为更新面板的所有异步事件的叠加层(使用 CSS)。现在,对于某些 EXPAND/COLLAPSE 行命令事件,我只是不想显示更新进度。

有办法吗?

【问题讨论】:

  • 在没有看到任何代码的情况下,听起来您应该能够将事件处理程序绑定到任何触发展开/折叠的事件。是点击事件吗?请发布您的代码。
  • 事件绑定好了,它只是我不想为包含在该更新面板中的 gridview 的某些 RowCommand 事件显示的 UpdateProgress 覆盖
  • 1.) 如果可能,请使用多个 UpdatePanel。 UpdateProgress-Control 有一个属性AssociatedUpdatePanelID。将 ID 设置为 UpdateProgress 为其显示状态的 UpdatePanel,并且不要对行命令的 UpdatePanel 使用 UpdateProgress 控件。 2.) 玩转DisplayAfter 属性,该属性指示何时显示UpdateProgress。也许这已经足够了。 3.) 自己触发UpdateProgress,看this link看技术。

标签: jquery asp.net ajax visual-studio


【解决方案1】:
<script type="text/javascript">
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_initializeRequest(InitializeRequest);

    function InitializeRequest(sender, args) {
        var updateProgress = $get('UpdateProgress1');
        var postBackElement = args.get_postBackElement();
        if (postBackElement.id == '<%= Button1.ClientID %>') {
            updateProgress.control._associatedUpdatePanelId = 'dummyId';
        }
        else{
            updateProgress.control._associatedUpdatePanelId = null;
        }
    }

</script>

【讨论】:

  • 好极了。很好理解并正确回答了这一点。谢谢
【解决方案2】:

我发现这对我有用,因为 Response.Redirect 会阻止重新加载原始页面,因此不会关闭 UpdateProgress..

在有问题的控件上添加

OnClientClick="disableProgress()"

然后把这个javascript放到页面上

<script type="text/javascript">

function disableProgress() {

var updateProgress = $get('<%=UpdateProgress1.ClientID%>');
var originalID = updateProgress.control._associatedUpdatePanelId;
updateProgress.control._associatedUpdatePanelId = 'dummyId';

setTimeout(function () { updateProgress.control._associatedUpdatePanelId = originalID; }, 1000);

}
</script>

这会暂时禁用 UpdateProgress 控件,然后在 1 秒后在客户端异步重新激活它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-26
    • 1970-01-01
    • 2012-01-11
    • 2022-01-25
    • 2010-09-08
    相关资源
    最近更新 更多