execute code when no items to be uploaded

  •  02-29-2012, 5:49 AM

    execute code when no items to be uploaded

    Hi
     
    I have the ajaxuploadaattachments control added to a page.
    I start the upload manually on button Save Click
    But when no items are selected in the uploader the code behind the button will not fire.
    When I do select itemsto be uploaded the code behind will fire.
     
    aspx code:
     
    1. <script type="text/javascript">  
    2.   
    3.     function submitbutton_click() {  
    4.         var submitbutton = document.getElementById('<%=btnSave.ClientID %>');  
    5.         var uploadimg = document.getElementById('<%=uplFiles.ClientID %>');  
    6.         if (!window.filesuploaded) {  
    7.             if (uploadimg.getqueuecount() > 0) {  
    8.                 uploadimg.startupload();  
    9.             }  
    10.             else {  
    11.                   
    12.                 submitbutton.click();  
    13.             }  
    14.             return false;  
    15.         }  
    16.         window.filesuploaded = false;  
    17.         return true;  
    18.     }  
    19.   
    20.     function CuteWebUI_AjaxUploader_OnError(msg) {  
    21.         alert("Algemene fout:" + msg);  
    22.         return false;  
    23.     }  
    24.     function CuteWebUI_AjaxUploader_OnTaskError(obj, msg, reason) {  
    25.         alert("Bestandfout:" + obj.FileName + " , " + msg);  
    26.         return false;  
    27.     }  
    28.   
    29.     function CuteWebUI_AjaxUploader_OnPostback() {  
    30.         window.filesuploaded = true;  
    31.         var submitbutton = document.getElementById('<%=btnSave.ClientID %>');  
    32.         submitbutton.click();  
    33.         return false;  
    34.     }  
    35.         </script>  
    The button code:
     
    1. <asp:Button runat="server" ID="btnSave" Text="Wijzigen" OnClick="btnSave_Click"  OnClientClick="return submitbutton_click()" />  
    The control code:
     
    1. <cc2:UploadAttachments ID="uplFiles" runat="server" ManualStartUpload="true"  
    2.                                 MaxFilesLimit="5" FileTooLargeMsg="Bestand is te groot! Max. 5 MB."  
    3.                                 MultipleFilesUpload="true" ShowProgressInfo="false" ShowProgressBar="false" InsertText="Kies uw bestanden"  
    4.                                 MaxFilesLimitMsg="U mag maximaal 5 bestanden uploaden" RemoveButtonText="Verwijder" ShowTableHeader="false"  
    5.                                 ShowFileIcons="true" CancelAllMsg="Verwijder alles">  
    6.                                 <ValidateOption MaxSizeKB="5120" AllowedFileExtensions="pdf,doc,docx,xls,xls,rtf,txt" />  
    7.                             </cc2:UploadAttachments>  
    Please help.  
View Complete Thread