Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Ajax
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)
    {
  
        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;
 
        }
    }
Posted 10-Jun-13 20:55pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

hi i had used progress bar in my website as follow and it works fine
 
Home.aspx:
 
<pre lang="css"><style>
.loading
    {
        font-family: Arial;
        font-size: 10pt;
        border: 5px solid #67CFF5;
        width: 200px;
        height: 100px;
        display: none;
        position: fixed;
        background-color: White;
        z-index: 999;
    }
 
    </style>;
 
<script type="text/javascript" language="javascript">;
 
 function ShowProgress() {
        setTimeout(function () {
            var modal = $('<div />');
            modal.addClass("modal");
            $('body').append(modal);
            var loading = $(".loading");
            loading.show();
            var top = Math.max($(window).height() / 2 - loading[0].offsetHeight / 2, 0);
            var left = Math.max($(window).width() / 2 - loading[0].offsetWidth / 2, 0);
            loading.css({ top: top, left: left });
        }, 200);
    }
    $('form').live("submit", function () {
        ShowProgress();
    }); 
// Get the instance of PageRequestManager.
             var prm = Sys.WebForms.PageRequestManager.getInstance();
             // Add initializeRequest and endRequest
             prm.add_initializeRequest(prm_InitializeRequest);
             prm.add_endRequest(prm_EndRequest);
            
             // Called when async postback begins
             function prm_InitializeRequest(sender, args) {
                 // get the divImage and set it to visible
                 var panelProg = $get('divImage');                
                 panelProg.style.display = '';
                 // reset label text
                 var lbl = $get('<%= this.lblText.ClientID %>');
                 lbl.innerHTML = '';
 
                 // Disable button that caused a postback
                 //$get(args._postBackElement.id).disabled = true;
             }
 
             // Called when async postback ends
             function prm_EndRequest(sender, args) {
                 // get the divImage and hide it again
                 var panelProg = $get('divImage');                
                 panelProg.style.display = 'none';
 
                 // Enable button that caused a postback
                 $get(sender._postBackSettings.sourceElement.id).disabled = false;
             }
 
</script>
    <div class="testwhleinside">
        <asp:updatepanel id="UpdatePanel1" updatemode="Conditional" runat="server" xmlns:asp="#unknown">
            <contenttemplate>
                <div>
                 <div class="loading" align="center" id="divImage">
                 
<asp:label id="lblText" runat="server" text=""></asp:label>                 
    Submitting Timesheet..<br />
    <br />
    <img src="../images/loader.gif" alt="" />
</div>
 
</div></contenttemplate></asp:updatepanel></div>
 

Home.aspx.cs:
 

protected void Page_Load(object sender, EventArgs e)
{
 
if (!IsPostBack)
{
Session["Timesheet"] = "false";
string script = "$(document).ready(function () { $('[id*=BtnId]').click(); });";
ClientScript.RegisterStartupScript(this.GetType(), "click", script, true);
}
}
  Permalink  
v2
Comments
Aysha Patel at 11-Jun-13 2:20am
   
If u have still problem with my code then let me know...
Happy coding :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You can get better solutions to your problem on how to Show progress bar using UpdateProgress control in asp.net(C#, VB)
http://www.webcodeexpert.com/2013/05/show-progress-image-using.html[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 240
1 Kamal Rocks 184
2 CPallini 155
3 PIEBALDconsult 150
4 BillWoodruff 148
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 11 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100