ClientFileUploadRemoving - How can you work out if someone is removing an invalid file

4 posts, 0 answers
  1. Lachlan
    Lachlan avatar
    3 posts
    Member since:
    Jan 2013

    Posted 22 Jan 2013 Link to this post

    I was trying to implement some nicer client side error handling informing the user why the upload failed as the exisiting client feedback is just a red dot instead of a green dot, so I followed this example 
    http://demos.telerik.com/aspnet-ajax/asyncupload/examples/validation/defaultcs.aspx

    But I am now trying to work out how to hide the error message when the user clicks remove on an invalid file.

    I looked at OnClientFileUploadRemoving, but that only gets triggered if a valid file is removed.

    Also, is there something similar to the upload.isExtensionValid method that checks if the file size is valid? 

    Thanks

  2. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 25 Jan 2013 Link to this post

    Hello Lachlan,

    Please review the following client side event.

    Greetings,
    Peter Filipov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Lachlan
    Lachlan avatar
    3 posts
    Member since:
    Jan 2013

    Posted 25 Jan 2013 Link to this post

    Hi Peter, 

    Thanks for the reply.

    I am already using the:
    function OnClientValidationFailed(sender, args)
    I use that to display the error message, and that is being triggered fine.

    What i want to know is what event is fired when a user clicks Remove  on an invalid file. So when a user clicks remove on an invalid file I would like to remove the error message. It seems that when a valid file is removed the ClientFileUploadRemoving method is triggered, but not for invalid files.

    Thanks

    Lach
  5. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 30 Jan 2013 Link to this post

    Hello Lachlan,

    Please try the following code and let me know if it helps.
    <form id="form1" runat="server">
    <div>
        <telerik:RadScriptManager runat="server" ID="RadScriptManager"></telerik:RadScriptManager>
        <telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1" AllowedFileExtensions=".jpg" OnClientFileUploadRemoving="onClientFileUploadRemoving"></telerik:RadAsyncUpload>
    </div>
    </form>
    <script type="text/javascript">
        function onClientFileUploadRemoving(sender, args) {
            var row = args.get_row(),
                $ = $telerik.$,
                isValidFile = $(row).find(".ruUploadSuccess").length > 0;
     
            if (isValidFile)
                alert("You are removing Valid file");
            else
                alert("You are removing Invalid file");
        }
    </script>

    Regards,
    Peter Filipov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top