Clear Uploader Files On Error

Last post 08-23-2010, 4:14 PM by Eric. 1 replies.
Sort Posts: Previous Next
  •  08-20-2010, 12:14 PM 63543

    Clear Uploader Files On Error

       Hello,
     
    I have an upload control with manual start.  I would like to clear out the files listed to upload when an error occurs on postback as the control shows they are still there. Although when you click on "Upload" again it will say "Please select files to upload".  I have tried the DeleteAllAttachments() method but that didn't work.  Is there another solution?  Thank you very much!
  •  08-23-2010, 4:14 PM 63576 in reply to 63543

    Re: Clear Uploader Files On Error

    You can use OnError event to hide the default error message alert box.
     
    function CuteWebUI_AjaxUploader_OnError(msg)
    {
          return false;
    }

    The following is one runnable example:
    <%@ Page Language="C#" %>
    <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
     protected void UploadAttachments1_FileValidating(object sender, UploaderEventArgs args)
     {
      if (args.FileSize > 5)
       throw (new Exception("file should not larger then 10K"));
     }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
     <title>Untitled Page</title>
    </head>
    <body>
     <form id="form1" runat="server">
      <div>
       <CuteWebUI:UploadAttachments runat="server" ID="UploadAttachments1" OnFileValidating="UploadAttachments1_FileValidating">
       </CuteWebUI:UploadAttachments>
      </div>
      <div id="diverrormsg">
      </div>
     </form>
     <script type="text/javascript">
         function CuteWebUI_AjaxUploader_OnError(msg) {
             return false;
         } 
     </script>
    </body>
    </html>
     
     
    Regards,
    Eric

     

View as RSS news feed in XML