UpdateProgress not working

4.8k views Asked by At

I have an UpdateProgress and I'm trying to show a loading gif while post back
but this code doesn't work when I click the button.

There is nothing happens with with this code and no post back on button click.

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1" DynamicLayout="true">
    <ProgressTemplate>
        <asp:Image ID="ImageWait" runat="server" ImageUrl="../images/wait.gif" />
    </ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
       <asp:Button ID="ButtonSave" runat="server" Text="Save" OnClick="ButtonSave_Click" ValidationGroup="Valid1" />
    </ContentTemplate>
</asp:UpdatePanel>   

protected void ButtonSave_Click(object sender, EventArgs e)
{
    // Some code
}

How can I fix this?

2

There are 2 answers

3
AudioBubble On BEST ANSWER
  • Set UpdateMode of your UpdatePanel to Conditional
  • Manually trigger AsyncPostBackTrigger to your controls inside UpdatePanel and give the ControlID and EventName that will fire:

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" >
        </ContentTemplate>
            <asp:Button ID="ButtonSave" runat="server" Text="Save" 
                OnClick="ButtonSave_Click" />
        </ContentTemplate>
        <Triggers>   
            <asp:AsyncPostBackTrigger ControlID="ButtonSave" 
                EventName="Click" />
         </Triggers>
    </asp:UpdatePanel>

  • Give an associated UpdatePanel's ID to UpdateProgress:

    <asp:UpdateProgress ID="UpdateProgress1" runat="server" 
        AssociatedUpdatePanelID="UpdatePanel1">
    
  • And you can test its working in events using System.Threading.Thread.Sleep(3000);:

    protected void ButtonSave_Click(object sender, EventArgs e)
    {
        // delay it for 3 milliseconds
        System.Threading.Thread.Sleep(3000);
    
       //... Here will be your logic
    }
    
0
maozx On

by default (whan no value is set in the UpdateProgress control)

DisplayAfter="500" 

If your postback is "too fast", UpdateProgress will not show... Try setting it to:

DisplayAfter="1" 

to check if it's working, and than set your desired value