How to show update progress while uploading file content to sql server database?

Posted by Prabu_Spark under ASP.NET AJAX on 6/11/2013 | Points: 10 | Views : 2736 | Status : [Member] | Replies : 1
Hi sir,
Tell me the steps to show update progress while uploading file content to sql server database. I have
40,000 records in excel file, i upload the records into the database, i need to show update progress
while uploading the records into database, its working fine but i cant able to view the update progress.
I attached the code for further details. Kindly give me the solution for this problem.



Homes.aspx:
**************

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<br />
<br />
<br />
<br />


<asp:UpdatePanel ID="UpdatePanel1" runat="server">


<ContentTemplate>

<table align="center">
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Please select the file"></asp:Label>
</td>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" />
</td>
<td>



</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td>
&nbsp;</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td align="center" colspan="3">
<%--<asp:GridView ID="GridView1" runat="server">
</asp:GridView>--%>
<asp:Label ID="lbl_count" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td align="center" colspan="3">
&nbsp;</td>
</tr>
</table>



<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Upload" OnClientClick="javascript:showWait();" />



<asp:UpdateProgress AssociatedUpdatePanelID="UpdatePanel1" ID="UpdateProgress1" runat="server">
<ProgressTemplate>

<asp:Image ID="Image1" runat="server" ImageUrl="~/images/ajax-loader.gif" />
</ProgressTemplate>
</asp:UpdateProgress>

</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="Button1" />
<%-- <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />--%>
</Triggers>
</asp:UpdatePanel>



<br />
<br />


Homes.aspx.cs
**************************


protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
if (FileUpload1.HasFile)
{
string filename = FileUpload1.FileName;
if (System.IO.File.Exists(Server.MapPath(filename)))
{

System.IO.File.Delete(Server.MapPath(filename));
}

string count;
FileUpload1.SaveAs(Server.MapPath(filename));

import_excel(Server.MapPath(filename), out count);

lbl_count.Text = count;

}
}

With regards,
J.Prabu.
[Email:prbspark@gmail.com]



Responses

Posted by: Chvlsru on: 6/13/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

Put your file file upload control in one update panel and also place the controls in the same panel which you want to update after file upload .

2. Now place an asp:updateprogress from tool box(AJAX Extension Tab) to just above the update panel.

3. Place progress rotating GIF image in the update progress section,

4. Use below code to configure update progress


<asp:UpdateProgress ID="UpdateProgress1"
AssociatedUpdatePanelID="YourUpdatePanelControlID" runat="server">
<ProgressTemplate><asp:Literal ID ="Literal" Text="Progressing....." runat="server"></asp:Literal>
<!-- here you can also place rotating image, when ever YourUpdatePanelControlID content is geting updatedmthen this image will be visible automatically true-->
</ProgressTemplate>
</asp:UpdateProgress>

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

Login to post response