Show Progress label when saving to database

Last post 07-03-2010, 2:39 AM by cutechat. 3 replies.
Sort Posts: Previous Next
  •  06-23-2010, 5:11 AM 61956

    Show Progress label when saving to database

    Hi,
     
    I have successfully created a upload session, and after upload, the FileUploaded is trigged.
    In this I save the file to a database, and I have portioned this up in smaller units, using column.write to a varbinary(max) column, since the upload will deal with files several hundred MB large. The problem is that it will take several seconds to do these savetoDB calls. So how can I within my FileUploaded procedure use a control to show the progress. Let's say as a simple label:
    for(int step; step<=steps;step++)
    {
       Label1.text = "Saving uploaded file to database step "+step+" of "+steps;
       ... ...
    }
    I have no problem with the portioning nor the sql calls, but I can't manage to refresh a label within the FileUploaded procedure.
     
    Thanks in advance for your help
    /Magnus
  •  06-25-2010, 1:23 AM 61994 in reply to 61956

    Re: Show Progress label when saving to database

    Hi Burken,
     
    Try this way
     
    1. <%@ Page Language="C#" %>   
    2.   
    3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
    4. <html xmlns="http://www.w3.org/1999/xhtml">   
    5. <head id="Head1" runat="server">   
    6.     <title>Untitled Page</title>   
    7. </head>   
    8. <body>   
    9.     <form id="form1" runat="server">   
    10.         <CuteWebUI:UploadAttachments ID="attachemnt1" runat="server">   
    11.         </CuteWebUI:UploadAttachments><br />   
    12.         <asp:Label ID="label1" runat="server"></asp:Label>   
    13.     </form>   
    14. </body>   
    15. </html>   
    16.   
    17. <script>   
    18. var label1 = document.getElementById("<%= label1.ClientID %>");   
    19. function CuteWebUI_AjaxUploader_OnProgress(enable,filename,begintime,uploadedsize,totalsize)   
    20.   
    21. {   
    22.     if(enable)   
    23.     {   
    24.       if(totalsize)   
    25.        {   
    26.         label1.innerHTML=filename+" - "+Math.floor(100*uploadedsize/totalsize)+'%'  
    27.        }   
    28.      }   
    29.       
    30. }   
    31.   
    32. </script>  
    Regards,
     
    ken
  •  06-29-2010, 2:01 PM 62080 in reply to 61994

    Re: Show Progress label when saving to database

    Hi Kenneth,
     
    I think he meant a progress update for his own server-side events, not client side Uploader-events.
    Like when he is saving the file to a database, so that the user doesn't get bored or confused.
     
    Bye
    A.
     
  •  07-03-2010, 2:39 AM 62260 in reply to 61956

    Re: Show Progress label when saving to database

    Hi,
     
    Currently we have no good ideas to let client show the server side progress directly.
     
    Now you can do this thing :
     
    1 , on the server FileValidating event, start a new thread to copy the filedata to database, and return the request directly.
    2 , on the client side, you can use the OnTaskComplete event, and start a new function to check the server side status.
     
    We will consider a buildin API for that cool feature.
     
    Regards,
    Terry
View as RSS news feed in XML