How to disable UpdateProgress for certain controls in ASP.NET?

I have a website developed using ASP.NET. There are many ajax requests. So I want to display the image when an ajax request occurs, and hide the image after loading the data. Now it works great,

Here is what I have done so far

<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="uppnlLocation"> <ProgressTemplate> <img src="images/loading.gif" /> </ProgressTemplate> </asp:UpdateProgress> <asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="uppnlLocation"> <ContentTemplate> <asp:DropDownList ID="ddContinents" runat="server" CssClass="form-control" OnSelectedIndexChanged="ddContinents_SelectedIndexChanged" AutoPostBack="true"> </asp:DropDownList> <asp:TreeView runat="server" ID="tvCountries" OnSelectedNodeChanged="tvCountries_SelectedNodeChanged"></asp:TreeView> </ContentTemplate> </asp:UpdatePanel> 

So, in the above code, when the user selects a continent from the drop-down list, the countries that belong to this continent will be loaded into the lower tree. Therefore, I want to display the boot image when the user selects a continent from the drop-down list when loading countries. Now it works. But the problem is when the user selects the node tree in treeview. It also shows this progress control image. I do not want to display this image in this action. How to disable it?

I saw a message about this.

Is there a way to disable UpdateProgress for specific asynchronous postbacks?

I implemented this. but there’s no postback in the drop-down menu.

So how to achieve this?

Many thanks.

+4
source share
2 answers

It is best to use the DisplayAfter parameter to raise the delay that appears because I understand that this is happening so fast. Don't go with complicated javascript solutions, just add a delay of 1 or 2 seconds ...

 <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="uppnlLocation" DisplayAfter="2000"> <ProgressTemplate> <img src="images/loading.gif" /> </ProgressTemplate> </asp:UpdateProgress> 
0
source

Well, why not just use javascript to display it if everything is okay with it ... For a normal update panel and for invoking progress, updates are not always displayed. It is better to use javascript to show update progress, and not to use the default methods.

Upgrade Progress Code

 function showUpdateProgress() { var updateProgress = document.getElementById("<%=upProgress.ClientID%>"); updateProgress.style.display = 'block'; } function HideUpdateProgress() { var updateProgress = document.getElementById("<%=upProgress.ClientID%>"); updateProgress.style.display = 'none'; Sys.Application.remove_load(HideUpdateProgress); } 

If you use this method when your work is done in the code behind, you need to call javascript to hide the update progress.

According to the following

In cs file

 ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Script", "Sys.Application.add_load(HideUpdateProgress);", true); 

Hope this help helps you.

0
source

All Articles