Do not show files that fail validation

3 posts, 1 answers
  1. Baal
    Baal avatar
    47 posts
    Member since:
    Mar 2008

    Posted 15 Oct 2012 Link to this post



    In the above example, even though the second file Lighthouse.jpg fails validation, it in the file list. Although the green and red bullet show the status of each file, it is not as intuitive, especially if you select multiple at a time. Firstly you have to scan through the list to see which all failed. Secondly colourblind people can have a hard time distinguishing them.

    How can I make it so that files that fail validation don't show up there? I'm planning to have a error area below the upload control that will list files that fail validation and only show validated files up there.

    Thanks.
  2. Answer
    Bruce
    Bruce avatar
    3 posts
    Member since:
    Apr 2012

    Posted 15 Oct 2012 Link to this post

    This is how I did it:
    function OnClientValidationFailed(sender, args) {
                var allowedExtensions = $(".uploadFileExtensions").html();
                alert('Sorry but that file extension is not allowed. Only the following file extensions are allowed ' + allowedExtensions);
     
                var upload = document.getElementById('<%=radUpload.ClientID %>');
                var index = $(args.get_row()).index();
                sender.deleteFileInputAt(index);
            }


    Make sure you set the OnClientValidationFailed event up on the control:
    <telerik:RadAsyncUpload ID="radUpload" runat="server" AllowedFileExtensions="pdf,jpeg,jpg,png,ppt" OnClientValidationFailed="OnClientValidationFailed" />
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Baal
    Baal avatar
    47 posts
    Member since:
    Mar 2008

    Posted 15 Oct 2012 Link to this post

    Thanks Bruce. It works wonderfully.
Back to Top