FileValidating event not firing? Please help!

Last post 06-21-2009, 10:49 PM by cutechat. 2 replies.
Sort Posts: Previous Next
  •  06-18-2009, 8:39 AM 53260

    FileValidating event not firing? Please help!

    Here is the code for my upload control:
     
    <CuteWebUI:Uploader runat="server" ID="Uploader1" InsertText="Browse for Files"
                                ManualStartUpload="true"
                                MultipleFilesUpload="true"
                                MaxFilesLimit="10"
                                OnUploadCompleted="Uploader_UploadCompleted"
                                OnFileValidating="Uploader_FileValidating"
                                TempDirectory="~/___UploadTemp"
                                CancelButtonID="ButtonCancel"
                                >
                            <VALIDATEOPTION
                            AllowedFileExtensions="jpg,mp4,mp3,mov"
                            MaxSizeKB="256000"
                            />
                        </CuteWebUI:Uploader>
     
    I have this method setup:
     
         public void Uploader_FileValidating(object sender, UploaderEventArgs args)
        {
            DebugLabel.Text += "<br/>" + DateTime.Now + "FileValidating - " + args.FileName;

        }
     
    And in the OnInit event, I added this (I tried without this as well):
     
    Uploader1.FileValidating += new UploaderEventHandler(Uploader_FileValidating);
     
     
    For some reason the event is not firing...   Any ideas?
     
    Also, when this event fires should the files be ready to move?   I am doing a lot of operations (move, verify, create thumbs, etc) and the page hangs for a bit.  I can't figure out a reliable way to show a please wait message (and disable the browse/upload buttons) that will turn on once the upload button is clicked and turn off once all the operations are complete.
     
     
     
     
  •  06-18-2009, 12:12 PM 53265 in reply to 53260

    Re: FileValidating event not firing? Please help!

    On my working projects, I don't specify the OnFileValidating in the control but ONLY in the OnInit like so
    1. protected override void OnInit(EventArgs e)   
    2.     {   
    3.         base.OnInit(e);   
    4.         SampleUtil.SetPageCache();   
    5.   
    6.         Uploader1.FileValidating += new UploaderEventHandler(Uploader_FileValidating);   
    7.     }  
    SampleUtil.SetPageCache is a static class supplied by CuteWebUI in the ajaxuploader samples.
     
    And then, I make sure I Cast the Uploader control again in the Event method like so.
     
    1. void Uploader_FileValidating(object sender, UploaderEventArgs args)   
    2.     {   
    3.         Uploader uploader = (Uploader)sender;   
    4.         //do your stuff here   
    5.     }  
     
    Greg
  •  06-21-2009, 10:49 PM 53333 in reply to 53260

    Re: FileValidating event not firing? Please help!

    Hi,
     
    Any UI/ViewState changes in FileValidating will be ignored.
     
    You can throw an exception in that event handler, and use javascript to catch it :
     
    function CuteWebUI_AjaxUploader_OnError(msg)
    {
    return false;//hide the default alert
    }
     
    function CuteWebUI_AjaxUploader_OnTaskError(obj,msg,reason)  
    {
    //obj.FileName,obj...
    }
     
     
    Regards,
    Terry
     
View as RSS news feed in XML