CuteWebUI_AjaxUploader_OnError Doesn't Fire

Last post 02-25-2011, 10:02 AM by Eric. 5 replies.
Sort Posts: Previous Next
  •  02-22-2011, 2:31 PM 66368

    CuteWebUI_AjaxUploader_OnError Doesn't Fire

    I have a web control (.ascx) that I'm using the uploader on. Whenever I throw an exception from my C#,  CuteWebUI_AjaxUploader_OnError isn't firing, nor do any of the supposed Javascript events.
     
    I don't like the pop-up error message that is the default of the AjaxUploader. We use ValidationSummary instead, so I'd like to find a way to populate that instead but so far none of the solutions in the forums have worked.
     
    My HTML code:
     
    1. <ce:uploadattachments id="SkinResourceUploader" runat="server" showprogressbar="true" multiplefilesupload="true" inserttext="select files" uploadtype="Flash">   
    2.     <validateoption allowedfileextensions="jpeg,jpg,js,gif,png,css" />   
    3. </ce:uploadattachments>   
    4. <asp:requiredfieldvalidator id="RequiredValidator" controltovalidate="ErrorTextBox" runat="server" errormessage="file name error 1" />   
    5. <asp:textbox id="ErrorTextBox" runat="server" visible="true" />  
    6. <ce:uploadattachments id="SkinResourceUploader" runat="server" showprogressbar="true" multiplefilesupload="true" inserttext="select files" uploadtype="Flash">

      <validateoption allowedfileextensions="jpeg,jpg,js,gif,png,css" />

      </ce:uploadattachments>

      <asp:requiredfieldvalidator id="RequiredValidator" controltovalidate="ErrorTextBox" runat="server" errormessage="file name error 1" />

      <asp:textbox id="ErrorTextBox" runat="server" visible="true" />

      <script type="text/javascript">

      function CuteWebUI_AjaxUploader_OnError(msg) {

      alert(1);

      return false;

      }

      function CuteWebUI_AjaxUploader_OnTaskError(obj, msg, reason) {

      alert(1);

      return false;

      }

      function CuteWebUI_AjaxUploader_OnTaskStart(obj) {

      alert(1);

      }

      </script>

    My C# code does this:
     
    1. protected void SkinResourceUploader_FileValidating(object sender, CuteEditor.UploaderEventArgs args)   
    2.         {   
    3.             if (System.IO.File.Exists(ResourceFilePath + "Skin\\" + Skin.Id + "\\" + args.FileName))   
    4.             {   
    5.                 ErrorTextBox.Text = "file name error";   
    6.                 throw new Exception("test");   
    7.             }   
    8.         }  
  •  02-22-2011, 10:14 PM 66382 in reply to 66368

    Re: CuteWebUI_AjaxUploader_OnError Doesn't Fire

    Hi,
     
    Please test the example below. Upload a file large than 10 kb.
     
    1. <%@ Page Language="C#" %>  
    2.   
    3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    4.   
    5. <html xmlns="http://www.w3.org/1999/xhtml">  
    6. <head runat="server">  
    7.     <title>Untitled Page</title>  
    8. </head>  
    9. <body>  
    10.     <form id="form1" runat="server">  
    11.         <div>  
    12.             <CuteWebUI:UploadAttachments ID="uploader1" runat="server">  
    13.                 <ValidateOption MaxSizeKB="10" />  
    14.             </CuteWebUI:UploadAttachments>  
    15.         </div>  
    16.     </form>  
    17. </body>  
    18. </html>  
    19.   
    20. <script>  
    21.    function CuteWebUI_AjaxUploader_OnError(msg)  
    22.   
    23.     {  
    24.           if(msg.indexOf("The maximum file size allowed is set to")!=-1)  
    25.         {  
    26.             alert("This is a customized information");  
    27.             return false;  
    28.         }  
    29.     }  
    30. </script> 
    Regards,
     
    ken
  •  02-23-2011, 8:52 AM 66393 in reply to 66382

    Re: CuteWebUI_AjaxUploader_OnError Doesn't Fire

    Ken,
     
    Please test my example.
     
    While your example works, this doesn't address my issue. Your example is relying on an error message built into AjaxUploader. I'm throwing a custom error message from .Net code-behind, as my code example shows.
     
    Does AjaxUploader not support this? If not we can't purchase this product.
     
     
  •  02-23-2011, 2:35 PM 66401 in reply to 66393

    Re: CuteWebUI_AjaxUploader_OnError Doesn't Fire

    Dear mferrell3,
     
    Please follow steps:
     
    1. Save the following code to default.aspx

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script type="text/javascript">

    function CuteWebUI_AjaxUploader_OnError(msg) {
    alert(1);
    return false;
    }
    </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
          <CuteWebUI:UploadAttachments ShowFrameBrowseButton="false" InsertText="Upload Multiple files Now" runat="server"
                    ID="Attachments1" onfilevalidating="Attachments1_FileValidating" MultipleFilesUpload="true" >
                  
                </CuteWebUI:UploadAttachments>
        </div>
        </form>
    </body>
    </html>

    2. Save the following code to default.aspx.cs

    using System;
    using System.Collections.Generic;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void Attachments1_FileValidating(object sender, CuteWebUI.UploaderEventArgs args)
        {                 
                throw new Exception("test");       
        }
    }
    3. Run default.aspx and upload one file, you will find  CuteWebUI_AjaxUploader_OnError will be fired.
    Please check your snippet, check whether the highlighted line is called:
     if (System.IO.File.Exists(ResourceFilePath + "Skin\\" + Skin.Id + "\\" + args.FileName)) 
     {   
                 ErrorTextBox.Text = "file name error";   
                 throw new Exception("test");            
      }
     
    Thank you for asking
     
     
  •  02-24-2011, 10:15 AM 66420 in reply to 66401

    Re: CuteWebUI_AjaxUploader_OnError Doesn't Fire

    This code doesn't work; it's the same issue.  CuteWebUI_AjaxUploader_OnError never fires. "test" shows up in an alert, but alert(1) from the javascript in your example is never produced.
  •  02-25-2011, 10:02 AM 66451 in reply to 66420

    Re: CuteWebUI_AjaxUploader_OnError Doesn't Fire

    Dear mferrell3,
     
    I tested it again on my end, it works fine.
    Please follow the following steps and test it again, if it doesn't work, please let me know.
    1. Download ajax uploader, download link is http://cutesoft.net/downloads/folders/upload/entry44395.aspx
    2. Unzip this installation package
    3. Open IIS
    4. Switch to "Default Web Site" in left tree, right click it, add one virtual directory or application and let it point to "Ajax-Uploader\Framework 2.0-Csharp",you can also point to other same level folder,  name virtual directory or application as "test"
    5. You can visit examples by http://localhost/test//Demo.htm
    6. Save the following snippet to default.aspx:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script type="text/javascript">

    function CuteWebUI_AjaxUploader_OnError(msg) {
    alert("CuteWebUI_AjaxUploader_OnError is fired");
    return false;
    }
    </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
          <CuteWebUI:UploadAttachments ShowFrameBrowseButton="false" InsertText="Upload Multiple files Now" runat="server"
                    ID="Attachments1" onfilevalidating="Attachments1_FileValidating" MultipleFilesUpload="true" >
                  
                </CuteWebUI:UploadAttachments>
        </div>
        </form>
    </body>
    </html>

    7. Save the following to default.aspx.cs:
     

    using System;
    using System.Collections.Generic;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void Attachments1_FileValidating(object sender, CuteWebUI.UploaderEventArgs args)
        {                 
                throw new Exception("test");       
        }
    }

    8.  After done, please run http://localhost/test/default.aspx:
     
    Thank you for asking
View as RSS news feed in XML