Ajax UpdateProgress timeframe [Resolved]

Posted by Sharpcnet under C# on 3/11/2014 | Points: 10 | Views : 2180 | Status : [Member] | Replies : 3
<asp:UpdateProgress runat="server" AssociatedUpdatePanelID="UpdatePanel1" >  
<ProgressTemplate>
<asp:Image ImageUrl="/images/progress.gif"/>
</ProgressTemplate>
</asp:UpdateProgress>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
//gridview, textbox and button controls
</asp:UpdatePanel>


When testing this page on a local machine, the database tasks complete in a second. Maybe that's the reason the progress image doesnt show up. So I tried this..

btnSave_Click()
{
System.Threading.Thread.Sleep(3000);
//Code to save record to DB , bring back some data and bind to grid
}


Now, after clicking on btnSave, the image appears for 3 seconds and the DB task is done.

Here is the Question. When hosted on a server, the tasks might take 5-10 sec. So, in this case, will the image stay until the task is done or will it just stay for 3 secs, irrespective of the status of task.

I actually want to show the image until the tasks are done.




Responses

Posted by: Allemahesh on: 3/11/2014 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
You code is perfect. It will show image until the server or db task is done.
You can try to see your self. Just increase the System.Threading.Thread.Sleep(10000); to some more the it will show till the task finished.

See the below example:-

<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<asp:Image ImageUrl="/images/progress.gif" runat="server" />
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="btnSubmit" runat="server" Text="Submit"
onclick="btnSubmit_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>



public partial class _Default : System.Web.UI.Page 
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void btnSubmit_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
}
}


Hope you understand.

Sharpcnet, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sharpcnet on: 3/11/2014 [Member] Starter | Points: 25

Up
0
Down
Thank you very much

Sharpcnet, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 3/11/2014 [Member] [MVP] Silver | Points: 25

Up
0
Down
If the solution will help you, please click on Make As Answer.

Happy Coding.

Sharpcnet, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response