OnUploadCompleted doesn't fire

Last post 10-04-2012, 5:01 AM by WebsterTompkins. 4 replies.
Sort Posts: Previous Next
  •  10-02-2012, 10:25 AM 74836

    OnUploadCompleted doesn't fire

    Hi,

    I had AjaxUploader working pretty much as I wanted it. Then my boss requested me to change some parts (mainly UI).

    And now, for some reason, neither OnUploadCompleted nor OnFileUploaded fire anymore. OnFileValidating still fires when its supposed to. 

    Here is my Uploader

    <CuteWebUI:UploadAttachments ID="AjaxUpload" TempDirectory="~/App_Data/UploadTemp" CancelButtonID="btCancelUpload"  ProgressCtrlID="UploadPanel" ProgressTextID="UploadLabel" MultipleFilesUpload="True"  ManualStartUpload="True" OnUploadCompleted="UploadCompleted" OnFileValidating="CheckFileSize" OnFileUploaded="FileUploadCompleted" runat="server" >
                                         </CuteWebUI:UploadAttachments> 


    Any help finding the error is greatly apprecheated. 

    Filed under: ,
  •  10-02-2012, 8:05 PM 74839 in reply to 74836

    Re: OnUploadCompleted doesn't fire

    Hi,

     

    Can you descript what you changed ?

     

    Can you monitor the  TempDirectory , to check whether the file does exist after file validating ?

     

    Regards,

    Terry

     

  •  10-04-2012, 2:57 AM 74852 in reply to 74839

    Re: OnUploadCompleted doesn't fire

    Hi Terry, 

     

    Thanks for your reply.

     

    The changes i made shouldnt affect the OnUploadCompleted method. I only changed the UI arround the uploader and added the following BLOCKED SCRIPT

     

        function CuteWebUI_AjaxUploader_OnStop() {
            var submit = document.getElementById('<%=btSubmit.ClientID %>');
            var cancel = document.getElementById('<%=btCancelUpload.ClientID %>');
            var span = document.getElementById('<%=span_upload.ClientID %>');
            span.removeChild(submit);
            span.removeChild(cancel);
            span.appendChild(submit);
            span.appendChild(cancel);
            var hidden = this;
            hidden.internalobject.insertBtn.style.display = '';
            document.getElementById('<%=btSubmit.ClientID %>').style.visibility = 'visible';
        }


                function CuteWebUI_AjaxUploader_OnInitialize() {
                    var uploader = document.getElementById("<%=AjaxUpload.ClientID %>");
                    uploader.handlequeueui = myqueueuihandler;
                }

        function myqueueuihandler(list) {
            //        if (list.length < 2) {
            //            document.getElementById('<%=queuediv.ClientID %>').style.display = "none";
            //        }
            //        else {
            document.getElementById('<%=queuediv.ClientID %>').style.display = "";
            var container = document.getElementById('<%=queuedivtablecontainer.ClientID %>');
            container.innerHTML = "";

            var table = document.createElement("table");
            table.style.borderCollapse = "collapse";
            table.cellSpacing = 0;
            table.cellPadding = 4;
            table.border = 1;
            table.borderColor = "darkgreen";

            for (var i = 0; i < list.length; i++) {
                if (list[i].Status != 'Error') {
                    var name = list[i].FileName;
                    var size = list[i].FileSize; // (or -1)
                    var stat = list[i].Status; // Finish|Error|Upload|Queue
                    var func = list[i].Cancel;
                    var row = table.insertRow(-1);
                    row.insertCell(-1).innerHTML = name;
                    var last = row.insertCell(-1);
                    if (stat == "Queue") {
                        var btn = document.createElement("A");
                        btn.href = "BLOCKED SCRIPTvoid(0)";
                        btn.onclick = func;
                        btn.innerHTML = "Abbrechen";
                        last.appendChild(btn);
                    } else {
                        last.innerHTML = stat;
                    }
                }
            }
            container.appendChild(table);
            //}
            return false; //hide the default;
        }

        function cancelalltasks() {
            var uploader = document.getElementById("<%=AjaxUpload.ClientID %>");
            uploader.cancelall();
        } 

     

    The JavaScript I already had before is this:

        function submitbutton_click() {
            if (!ValidatorOnSubmit())
                return false;
            
            var uploadobj = document.getElementById('<%=AjaxUpload.ClientID %>');
            if (uploadobj.getqueuecount() == 0)
                return false;

            try {
                var submit = document.getElementById('<%=btSubmit.ClientID %>');
                var cancel = document.getElementById('<%=btCancelUpload.ClientID %>');
                var span = document.getElementById('<%=span_upload.ClientID %>');
                submit.style.visibility = 'hidden';
                cancel.style.visibility = 'visible';
                span.removeChild(submit);
                span.removeChild(cancel);
                span.appendChild(cancel);
                span.appendChild(submit);
            } catch(e) {
                alert(e);
            } 
            
            if (!window.filesuploaded) {
                if (uploadobj.getqueuecount() > 0) {
                    uploadobj.startupload();
                }
                return false;
            }
            window.filesuploaded = false;
            return true;
        }  
        function CuteWebUI_AjaxUploader_OnPostback() {
            window.filesuploaded = true;
            var submitbutton = document.getElementById('<%=btSubmit.ClientID %>');
            submitbutton.click();
            return false;
        }

                

  •  10-04-2012, 3:11 AM 74854 in reply to 74852

    Re: OnUploadCompleted doesn't fire

    oh and yes, the file exists after the validation
  •  10-04-2012, 5:01 AM 74856 in reply to 74854

    Re: OnUploadCompleted doesn't fire

    I finally figured out the problem:

    //         function submitbutton_click() {
    //             if (!ValidatorOnSubmit())
    //                 return false;
    //             var submitbutton = document.getElementById('<%=btSubmit.ClientID %>');
    //             var uploadobj = document.getElementById('<%=AjaxUpload.ClientID %>');
    //             if (!window.filesuploaded) {
    //                 if (uploadobj.getqueuecount() > 0) {
    //                     uploadobj.startupload();
    //                 }
    //                 return false;
    //             }
    //             window.filesuploaded = false;
    //             return true;
    //         }

             function submitbutton_click() {
                 if (!ValidatorOnSubmit())
                     return false;

                 var uploadobj = document.getElementById('<%=AjaxUpload.ClientID %>');
                 if (uploadobj.getqueuecount() == 0)
                     return false;

                 try {
                     var submit = document.getElementById('<%=btSubmit.ClientID %>');
                     var cancel = document.getElementById('<%=btCancelUpload.ClientID %>');
                     var span = document.getElementById('<%=span_upload.ClientID %>');
                     submit.style.visibility = 'hidden';
                     cancel.style.visibility = 'visible';
                     span.removeChild(submit);
                     span.removeChild(cancel);
                     span.appendChild(cancel);
                     span.appendChild(submit);
                 } catch (e) {
                     alert(e);
                 }

                 if (!window.filesuploaded) {
                     if (uploadobj.getqueuecount() > 0) {
                         uploadobj.startupload();
                     }
                     return false;
                 }
                 window.filesuploaded = false;
                 return true;
             }

     

    the first version breaks the upload, the seccond one doesnt. I was trying to replace the upload button with the cancel button. is there any way to do this without breaking the upload?

View as RSS news feed in XML