Handle FileTooLarge, MaxFilesLimit and FileTypeNotSupport Message Client-Side

Last post 09-10-2012, 8:11 AM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  09-08-2012, 2:37 AM 74600

    Handle FileTooLarge, MaxFilesLimit and FileTypeNotSupport Message Client-Side

    1. <CuteWebUI:UploadAttachments ID="ImageUploader" runat="server" ManualStartUpload="True" 
    2.       MaxFilesLimit="4" MultipleFilesUpload="True" TempDirectory="~/Images/Temp/" 
    3.       onfileuploaded="ImageUploader_FileUploaded" InsertText="Scegli Immagini"
    4.       ShowFileIcons="true" InsertButtonID="ChooseButton"
    5.       ProgressCtrlID="UploadProgressBarPanel" CancelButtonID="UploadCancelButton" 
    6.       ProgressTextTemplate="Spediti %SEND% di %SIZE% - Tempo Stimato %T% Secondi"  
    7.       ProgressTextID="UploadProgressLabel"
    8.       ProgressPicture="../../Images/Meteora/ProgressBar.png" ProgressBarStyle="Continuous"   
    9.       
    10.       FileTooLargeMsg="MAXFILESIZE" MaxFilesLimitMsg="MAXFILELIMIT"  
    11.       FileTypeNotSupportMsg="FILETYPE" ProgressPanelWidth="600" ProgressBarHeight="20">  
    12.             <ValidateOption AllowedFileExtensions="jpg,jpeg,png,gif,bmp" MaxSizeKB="3072" />  
    13. </CuteWebUI:UploadAttachments>
    14. <div id="UploadErrorDiv" style="display: none;"></div>
       

    Hi, i can't find any solution in this forum, for my problem. I this code i have an UploadAttachments Control, and i have set the FileTooLargeMsg, MaxFilesLimitMsg and FileTypeNotSupportMsg properties. When users select more than 4 files, a classic javascript alert windows is shown with the MAXFILELIMIT message.

    Is there any possibility to show themessage into the UploadErrorDiv??

    I have try to handle this kind of errors with this javascript function, but nothing happens!

     

    1. function CuteWebUI_AjaxUploader_OnError(msg)  
    2.         {  
    3.             var message = msg;  
    4.             switch (msg)  
    5.             {  
    6.                 case "MAXFILESIZE":  
    7.                     message = "Attenzione! I file inseriti possono essere di massimo 3MB ciascuno!";  
    8.                     break;  
    9.                 case "FILETYPE":  
    10.                     message = "Attenzione! Sono consentiti solo file jpg, png, gif, bmp!";  
    11.                     break;  
    12.                 case "MAXFILELIMIT":  
    13.                     message = "Attenzione! Sono consentiti 4 file alla volta!";  
    14.                     break;  
    15.             }  
    16.               
    17.             $("#UploadErrorDiv").html(message);  
    18.             $("#UploadErrorDiv").attr("style""display: block;");  
    19.             return false//cancel the default alert box  
    20.         }  
    Simply the CuteWebUI_AjaxUploader_OnError() is not called! have you any suggestion on this problem?

     Thank you

  •  09-10-2012, 8:11 AM 74607 in reply to 74600

    Re: Handle FileTooLarge, MaxFilesLimit and FileTypeNotSupport Message Client-Side

    Hi anloboz,

     

    For now can not catch the  "MaxFilesLimit" error at client side. Sorry for your inconvenience.

     

    maybe you try try another way to limit the max files, like below. Then you can handle it at client side. 

     

    <script type="text/javascript">
    function CuteWebUI_AjaxUploader_OnSelect(files)
    {
       if(files.length>4)
       {
            alert("Attenzione! Sono consentiti 4 file alla volta!");
            return false;
       }
    }
    </script>

     

     

    Regards,

     

    Ken 

View as RSS news feed in XML