Is there a way to disable UpdateProgress for certa

2020-02-07 06:16发布

问题:

I have an UpdateProgress control, that shows as an overlay (using CSS) for all async events for an update panel. Now, for certain EXPAND/COLLAPSE row command events, i just dont want to show that updateprogress.

Is there a way?

回答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:

I found this works for me where a Response.Redirect prevents the original page being reloaded & therefore the UpdateProgress does not get turned off..

On the offending control add

OnClientClick="disableProgress()"

and then put this javascript on the page

<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>

This temporarily disables the UpdateProgress control and then asynchronously reactivates it client-side after 1 second.