Validating and providing feedback

Last post 11-23-2009, 3:10 PM by scpeterson. 3 replies.
Sort Posts: Previous Next
  •  11-10-2009, 12:40 PM 57035

    Validating and providing feedback

    Hello:
     
    I am using the FileValidating event to check for duplicate files.  If I find a duplicate file, I execute an args.Delete() to remove the file so that the FileUploaded event does not fire for that file.  I want to record the names of each file that is a duplicate and present that list to my users.  I've tried adding the names to a label, but the label gets cleared out each time I go back to the FileValidating event.  I tried adding the information to a Session variable but that did not seem to work either.  I tried populating a label in the UploadCompleted event, but if all my files are duplicates, that event will never fire.
     
    Any ideas on how to do this would be most welcome. 
  •  11-16-2009, 9:45 PM 57196 in reply to 57035

    Re: Validating and providing feedback

    Hi,
     
    You have two solution :
     
    1 , throw an exception in the event handler, and uploader will show the exception message.
     
    2 , try this way :
     
     
    Regards,
    Terry
  •  11-23-2009, 3:09 PM 57353 in reply to 57196

    Re: Validating and providing feedback

    I tried method 2 and it seems to work just fine.  In the FileValidating event, I used a string that tells the user that the file already exists and so the file will not be uploaded.  I then call args.delete() to remove that file so it is not copied.  Since my uploaded files may or may not be duplicates, I need to test for a message in the alert and only display an alert if there is a message, i.e., the duplicate message I added in the FileValidating event:
     
     
    1. If System.IO.File.Exists(fullFileName) Then  
    2.    'The file already exists on the server so we need to delete it from the temporary  
    3.     '  upload directory (so it doens't get called in the FileUploaded event) and alert the user  
    4.   
    5.                  UploadAttachments1.SetValidationServerData(String.Format("A file named {0} already exists and will not be uploaded.", args.FileName))  
    6. args.Delete()  
    7.   
    8. End If
  •  11-23-2009, 3:10 PM 57354 in reply to 57353

    Re: Validating and providing feedback

    I also modified the JS script as follows:
     
    1. function CuteWebUI_AjaxUploader_OnTaskComplete(file) {  
    2.             //You can set the custom data here, or use uploader.getitems()[i].ServerData)  
    3.             if (file.ServerData !=null && file.ServerData != '')  
    4.                 alert(file.ServerData);  
    5.         }  
     
View as RSS news feed in XML