UploadCompleted firing before all files are uploaded

Last post 02-01-2012, 3:50 PM by Kenneth. 7 replies.
Sort Posts: Previous Next
  •  01-22-2012, 5:12 PM 72787

    UploadCompleted firing before all files are uploaded

    HI,
          The UploadCompleted appers to be firing before all files have completed uploading.
         I have the UploadAttachments  in an update panel say UP1  and another update panel say UP2 with dropdowns, textboxes etc some of which cause a postback.  Both UP1 and UP2 are set to conditional.
           A postback in UP2 is causing the UploadCompleted to fire if at least one file has been uploaded even though the upload is in progress.
     
    Part of my code is pasted below.
    If while the upload is going on (and after at least one file has been uplaoded)- you click the button which says Click Me - the control will jump to UploadCompleted and set the hidden variable to C.
     
    Can you please tell me what I am doing wrong? I am trying to have the file upload go on in an update panel while the user continues to fill in data in the second update panel. And I need to capture which completed first so I do need the UploadComplete to file ONLY after the file uploads are all completed.
     
    Can you provide me an alternate solution?
     

     

     

    <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"

     

    CodeBehind="Default.aspx.cs" Inherits="LibraryUI.Web._Default" %>

     

     

     

    <script runat="server">

     

     

    protected void SubmitButton_Click(object sender, EventArgs e)

    {

    hdnFileUploadComplete.Value = "S"; //file upload started

     

    Uploader1.InsertButton.Enabled = false;

    Uploader1.CancelButton.Enabled = false;

    SubmitButton.Enabled = false;

    UpnlFileUpload.Update();

    }

     

    protected void Uploader1_UploadCompleted(object sender, UploaderEventArgs[] args)

    {

    hdnFileUploadComplete.Value = "C"; //file upload completed first

     

    UpnlFileUpload.Update();

    }

     

    </script>

     

    <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">

     

     

     

    </asp:Content>

     

    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

     

    <div style="float:right;padding-right:50px;" >

    <asp:HyperLink id="hlEdit" runat="server" CssClass="SiteLinkLarger" Text="Help" NavigateUrl="About.aspx"></asp:HyperLink>

    </div>

     

    <asp:UpdatePanel runat="server" ID="UpnlFileUpload" UpdateMode="Conditional" RenderMode="Block">

    <ContentTemplate>

    <asp:Panel ID="PnlFileUpload" runat="server" style="display:block" >

     

    <p> Select File(s) to be published : Max total file size allowed is 2 GB </p>

    <CuteWebUI:UploadAttachments runat="server" MultipleFilesUpload="true" ManualStartUpload="true" ID="Uploader1" MaxFilesLimit="50" InsertText="Browse Files"

    OnUploadCompleted="Uploader1_UploadCompleted" >

     

     

     

    </CuteWebUI:UploadAttachments>

     

    <br />

    <br />

     

    <asp:HiddenField id ="hdnFileUploadComplete" runat="server" />

    <br />

     

    <asp:Button runat="server" ID="SubmitButton" OnClientClick="return submitbutton_click()"

     

    Text="Done Selecting File(s)" OnClick="SubmitButton_Click" CausesValidation="false" />

     

     

     

    <asp:Button ID="btnCancelPublish" runat="server" text="Cancel All" OnClientClick="return cancelalltasks();" CausesValidation="false" Enabled="false"></asp:Button>

     

     

    <br /><br />

     

    </asp:Panel>

     

     

    </ContentTemplate>

     

    </asp:UpdatePanel>

     

    <asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional" RenderMode="Block">

    <ContentTemplate>

     

    <asp:Button ID="Button1" runat="server" Text="Click Me"/>

    </ContentTemplate>

     

    </asp:UpdatePanel>

     

     

     

    <script type="text/javascript">

     

    var filelist;

     

    function submitbutton_click() {

     

    var uploadobj = document.getElementById('<%=Uploader1.ClientID %>');

     

    if (!window.filesuploaded)

    {

     

    if (uploadobj.getqueuecount() > 0) {

    uploadobj.startupload();

     

    }

     

    if (uploadobj.getqueuecount() == 0) {

    alert("Please browse files for upload");

     

    return false;

    }

    }

    window.filesuploaded = false;

     

    return true;

    }

     

     

     

    function CuteWebUI_AjaxUploader_OnPostback() {

    window.filesuploaded = true;

     

    var submitbutton = document.getElementById('<%=SubmitButton.ClientID %>');

    submitbutton.click();

     

    return false;

    }

     

    function CuteWebUI_AjaxUploader_OnInitialize() {

    window.filesuploaded = false;

    }

     

    function cancelalltasks() {

    var uploadobj = document.getElementById('<%=Uploader1.ClientID %>');

    if (confirm("Are you sure you want to cancel?")) {

    uploadobj.cancelall();

    window.location.reload();

    return true;

    }

    else return false;

    }

     

    </script>

     

    </asp:Content>

     

  •  01-23-2012, 2:04 PM 72810 in reply to 72787

    Re: UploadCompleted firing before all files are uploaded

    Hi - any update on this.
    Were you able to reproduce this error with the sample I posted?
    Thanks!
  •  01-24-2012, 10:15 AM 72816 in reply to 72787

    Re: UploadCompleted firing before all files are uploaded

    Please check this example. When you click the post back, the form is post backed. However the file upload progress will only start when you click the submit button.

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  01-24-2012, 10:29 AM 72817 in reply to 72816

    Re: UploadCompleted firing before all files are uploaded

    HI,
     You did not read the sample. I am already using the manual mode. I want the file upload to start and at the same time allow users to  enter data.
    Please try the sample I sent and let me know if what I'm doing is possible or not.
  •  01-24-2012, 5:45 PM 72821 in reply to 72817

    Re: UploadCompleted firing before all files are uploaded

    Hi,
            It seems to be that your UploadCompleted event is firing on the 1st postback event on  the page instead of on the actual file Upload completetion.
    Please let me know if this is true.  Do you plan on fixing this or is there is a workaround?
     
    Thanks,
  •  01-24-2012, 8:21 PM 72822 in reply to 72817

    Re: UploadCompleted firing before all files are uploaded

    I suggest you check the source code of this example. http://ajaxuploader.com/demo/Start-uploading-manually.aspx
     
    If it works for you, please modify this example to meet your requirements.
     
    If you want us check your own code,  please create a simple aspx which can reproduce this issue.
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  01-27-2012, 12:12 PM 72849 in reply to 72822

    Re: UploadCompleted firing before all files are uploaded

    Adam,
     I did send the sample code. Please see my first Post
  •  02-01-2012, 3:50 PM 72900 in reply to 72849

    Re: UploadCompleted firing before all files are uploaded

    Hi Pbanerji,
     
    We have fixed this issue, please download the latest version and try again.
     
    Latest version download URL: http://ajaxuploader.com/download/Ajax-Uploader.zip
     
    Regards,
     
    Ken 
View as RSS news feed in XML