CuteWebUI:UploadAttachments - Require At Least One File Selected When ManualStartUpload="true"

Last post 12-20-2012, 7:53 AM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  12-19-2012, 1:41 PM 75489

    CuteWebUI:UploadAttachments - Require At Least One File Selected When ManualStartUpload="true"

    How do I require at least one file is selected when CuteWebUI:UploadAttachments has ManualStartUpload="true". I can see the files selected in the control (which have not been uploaded yet - hence PostFilesAttachments1.Items.Count = 0).

     

    Can one use an ASP.NET  RequiredFieldValidator or a CustomFieldValidator with CuteWebUI:UploadAttachments"  

    If so how?  If not, why not?

  •  12-20-2012, 7:53 AM 75504 in reply to 75489

    Re: CuteWebUI:UploadAttachments - Require At Least One File Selected When ManualStartUpload="true"

    Hi carlpr,

     

    Please try the example below, it require the user at least select a file for upload.

     

    1. <%@ Page Language="C#" %> 
    2.  
    3. <%@ Register Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" TagPrefix="CuteWebUI" %> 
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
    5.  
    6. <html xmlns="http://www.w3.org/1999/xhtml"
    7. <head id="Head1" runat="server"
    8.     <title>Start uploading manually</title> 
    9.     <link rel="stylesheet" href="demo.css" type="text/css" /> 
    10. </head> 
    11. <body> 
    12.     <form id="form1" runat="server"
    13.         <CuteWebUI:UploadAttachments runat="server" ManualStartUpload="true" ID="Uploader1" 
    14.             InsertText="Browse Files (Max 1M)"
    15.             <ValidateOption MaxSizeKB="1024" /> 
    16.         </CuteWebUI:UploadAttachments> 
    17.         <p> 
    18.             <asp:Button runat="server" ID="SubmitButton" Text="Submit" OnClientClick="return submitbutton_click()" /> 
    19.         </p> 
    20.         <script type="text/javascript"
    21.  
    22.             function submitbutton_click() { 
    23.                 var submitbutton = document.getElementById('<%=SubmitButton.ClientID %>'); 
    24.                 var uploadobj = document.getElementById('<%=Uploader1.ClientID %>'); 
    25.                 if (!window.filesuploaded) { 
    26.                     if (uploadobj.getqueuecount() > 0) { 
    27.  
    28.                         uploadobj.startupload(); 
    29.                     } 
    30.                     else { 
    31.                         var uploadedcount = parseInt(submitbutton.getAttribute("itemcount")) || 0; 
    32.                         if (uploadedcount > 0) { 
    33.                             return true
    34.                         } 
    35.                         alert("Please browse files for uploading"); 
    36.                     } 
    37.                     return false
    38.                 } 
    39.                 window.filesuploaded = false
    40.                 return true
    41.             } 
    42.             function CuteWebUI_AjaxUploader_OnPostback() { 
    43.                 window.filesuploaded = true
    44.                 var submitbutton = document.getElementById('<%=SubmitButton.ClientID %>'); 
    45.                 submitbutton.click(); 
    46.                 return false
    47.             } 
    48.         </script> 
    49.  
    50.         </div> 
    51.     </form> 
    52. </body> 
    53. </html> 
     

    Regards,

     

    Ken

View as RSS news feed in XML