Async upload how to reset control in OnClientFileSelected when file is not valid?

11 posts, 0 answers
  1. Ian
    Ian avatar
    29 posts
    Member since:
    Jun 2009

    Posted 10 Nov 2011 Link to this post

    Hello -

    I'm using the the RadAsyncUpload and i've wired up a client side handler to the OnClientFileSelected event. My goal is to alert the user that their file is not a valid extension and then  reset the control by removing the file that they attempted to upload. According to your documentation here I should be able to make use of the remove_fileSelected method to remove the file that the user attempted to upload and thus hopefully reset the control so the user can do a new upload.

    The problem I have is I can't find any documentation on your site for what the signature is for remove_fileSelected or how it should be used - what parameter needs to be passed to it. Here is my handler code, please help, and if possible please expound your documentation so this is more clear.

    Thanks.

    this.checkFileExtension = function (radUpload, args) {
        if (!radUpload.isExtensionValid(args.get_fileName())) {
            alert('Please upload images with .jpg, .gif, .png, .bmp, or .tif extensions.');
            radUpload.remove_fileSelected();
        }
    }



  2. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 14 Nov 2011 Link to this post

    Hi Ian,

    The remove_fileSelected method removes the event handler of the OnClientFileSelected event. The following sample code implements your scenario:

    <form id="form1" runat="server">
    <div>
        <telerik:RadScriptManager runat="server" ID="RadScriptManager">
        </telerik:RadScriptManager>
        <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" ViewStateMode="Enabled"
            AllowedFileExtensions=".png"
             OnClientValidationFailed="onClientValidationFailed">
        </telerik:RadAsyncUpload>
    </div>
    </form>
    <script type="text/javascript">
     
        function onClientValidationFailed(sender, args) {
            $telerik.$(".ruCancel").parent().remove();
            alert("Allowed files extension is png");
        }
     
    </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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ian
    Ian avatar
    29 posts
    Member since:
    Jun 2009

    Posted 18 Nov 2011 Link to this post

    This doesn't work. It just removes the whole control (probably because I have max file inputs set to 1), I still want the user to be able to select a different file after they've attempted upload of an invalid file. Please advise, thanks.
  5. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 22 Nov 2011 Link to this post

    Hello Ian,

    The RadAsyncUpload disappears because the MaxFileInputsCount is set to 1. Please try the following sample code to avoid that behavior.
    <form id="form1" runat="server">
    <div>
        <telerik:radscriptmanager runat="server" id="RadScriptManager">
    </telerik:radscriptmanager>
        <telerik:radasyncupload id="RadAsyncUpload1" runat="server" viewstatemode="Enabled" MaxFileInputsCount="1"
            allowedfileextensions=".png" onclientvalidationfailed="onClientValidationFailed">
    </telerik:radasyncupload>
    </div>
    </form>
    <script type="text/javascript">
        function onClientValidationFailed(sender, args) {
            $telerik.$(".ruCancel").parent().remove();
            alert("Allowed files extension is png");
            sender.addFileInput();
        }
    </script>


    Best wishes,
    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
  6. Ian
    Ian avatar
    29 posts
    Member since:
    Jun 2009

    Posted 22 Nov 2011 Link to this post

    This seems to work well, thanks.

    On a side note I've used Telerik products for several years, I would sum up my experience with your controls like this: great controls with terrible documentation. Surely i'm not the only one to comment on this, is this is something Telerik could improve? I think it needs more concrete examples and descriptions for each public method and property that is available on each control.

  7. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 24 Nov 2011 Link to this post

    Hi Ian,

    Thank you for your feedback. We will do our best to update the documentation. Regarding the RadAsyncUpload documentation you can find here all the methods used in the example below.

    All the best,
    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
  8. Lobna
    Lobna avatar
    14 posts
    Member since:
    Jan 2013

    Posted 09 Jan 2013 Link to this post

    when I try to upload file with RadAsyncUpload, it crashes when the file is open. 
    How to solve this?
    Thanks
  9. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 14 Jan 2013 Link to this post

    Hello Lobna,

    We had similar issue which is resolved in the latest version of our controls. Do you reproduce the issue on our online demos?

    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.
  10. Lobna
    Lobna avatar
    14 posts
    Member since:
    Jan 2013

    Posted 14 Jan 2013 Link to this post

    Thanks for your reply.

    No, on online demos there is no such problem. So I think I need to update my Version.
    I have v.2012.2.815.40, so I need to update it, right?
  11. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 17 Jan 2013 Link to this post

    Hello Lobna,

    Actually the issue is possible to come from the version of your Silverlight/Flash plugins. Before downloading the latest version of our controls you could try to set DisablePlugins property to true.

    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.
  12. Lobna
    Lobna avatar
    14 posts
    Member since:
    Jan 2013

    Posted 19 Jan 2013 Link to this post

    Hello Peter,

    It works fine after changing the 'DisablePlugins' property to true.

    Thanks alot,
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017