Re: FileValidated vs. FileUploaded events

  •  11-11-2009, 8:23 PM

    Re: FileValidated vs. FileUploaded events

    Rob,
     
    You can't update the server UI at the FileValidating event.
     
    Uploader provide a method to let you send some data to cient side, and then update the UI via JavaScript
     
    Please check this sample:
     
     
    1. <%@ Page Language="C#" %>  
    2.   
    3. <%@ Import Namespace="CuteWebUI" %>  
    4. <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>  
    5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    6.   
    7. <script runat="server">  
    8.   
    9.     protected void UploadAttachments1_FileValidating(object sender, UploaderEventArgs args)   
    10.     {   
    11.         //you can send some data or message to client side   
    12.         UploadAttachments1.SetValidationServerData("File validated at " + DateTime.Now.ToString("HH:mm:ss"));   
    13.   
    14.         //updating the UI has no effect!   
    15.         labelMsg.Text = "Validated!";   
    16.     }   
    17.   
    18.     protected void UploadAttachments1_FileUploaded(object sender, UploaderEventArgs args)   
    19.     {   
    20.            
    21.     }   
    22. </script>  
    23.   
    24. <html xmlns="http://www.w3.org/1999/xhtml">  
    25. <head id="Head1" runat="server">  
    26.     <title>Untitled Page</title>  
    27. </head>  
    28. <body>  
    29.     <form id="form1" runat="server">  
    30.         <div>  
    31.             <CuteWebUI:UploadAttachments runat="server" ID="UploadAttachments1" InsertText="Add files" OnFileValidating="UploadAttachments1_FileValidating" OnFileUploaded="UploadAttachments1_FileUploaded">  
    32.             </CuteWebUI:UploadAttachments>  
    33.             <br />  
    34.             <asp:Label runat="server" ID="labelMsg" />  
    35.         </div>  
    36.     </form>  
    37. </body>  
    38.   
    39. <script type="text/javascript">  
    40. function CuteWebUI_AjaxUploader_OnTaskComplete(file)   
    41. {   
    42.     //You can get the custom data here , (or using uploader.getitems()[i].ServerData)   
    43.     alert(file.ServerData);   
    44. }   
    45. </script>  
    46.   
    47. </html>  
     
    Regards,
    Terry
     
     
View Complete Thread