RadAsyncUpload and test

13 posts, 0 answers
  1. Carlos
    Carlos avatar
    83 posts
    Member since:
    Apr 2013

    Posted 22 Aug 2013 Link to this post

    Hi all,

    So how can i test if a file is the extension i want before it is posted on the page with the red signal.
    Whant i want to do its only put the one that are correct and message the wrong ones?

    Best Regards
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Aug 2013 Link to this post

    Hi Carlos,

    Please try the following Code Snippet that I have tried which works fine at my end.

    ASPX:
    <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" AllowedFileExtensions=".jpg,.png"
        OnClientValidationFailed="OnClientValidationFailed1">
    </telerik:RadAsyncUpload>

    JavaScript:
    <script type="text/javascript">
        function OnClientValidationFailed1(sender, args) {
            $telerik.$(".ruCancel").parent().remove();
            alert("Allowed files extension are .jpg, .png");
        }
    </script>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Carlos
    Carlos avatar
    83 posts
    Member since:
    Apr 2013

    Posted 23 Aug 2013 Link to this post

    Hi all, Thansk

    and in C#.

    Regards.
  5. Carlos
    Carlos avatar
    83 posts
    Member since:
    Apr 2013

    Posted 23 Aug 2013 Link to this post

    Tnaks Shinu,

    it does thje trick exept for que java script, i prefered in c#, but not all my problem are resolved the control hides itself after given the error it there a way only to reset it to the select file??

    Tanks and Regards
  6. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Aug 2013 Link to this post

    Hi Carlos,

    You can try the following JavaScript to prevent resetting the control if the selected files contain an invalid file.

    JavaScript:
    <script type="text/javascript">
        function OnClientValidationFailed(sender, args) {
            $telerik.$(args.get_row()).css("display", "none");
            alert("Allowed files extension is .jpg, .png");
        }
    </script>

    Thanks,
    Shinu.
  7. Carlos
    Carlos avatar
    83 posts
    Member since:
    Apr 2013

    Posted 26 Aug 2013 Link to this post

    Hi and thanks,

    What i want to do its resetting, clean the file if its not the one.

    Best regards
  8. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Aug 2013 Link to this post

    Hi Carlos,

    I am not sure about your requirement. I guess you don't want to show the invalid file from the selected files while uploading.The OnClientValidationFailed event will fire whenever an invalid file is selected to upload.

    ASPX:
    <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" AllowedFileExtensions=".jpg,.png"
        OnClientValidationFailed="OnClientValidationFailed1">
    </telerik:RadAsyncUpload>

    JavaScript:
    <script type="text/javascript">
        function OnClientValidationFailed1(sender, args) {
            $telerik.$(args.get_row()).empty(); // to hide the invalid file from displaying.
            //OR
            $telerik.$(args.get_row()).css("display", "none"); //to hide the invalid file from displaying.
     
            alert("Allowed files extension are .jpg, .png"); //to show an alert if invalid file is selected to upload.
        }
    </script

    So the above approach will not let the user upload an invalid file and show that file name while uploading. Can you please elaborate the issue.

    Thanks,
    Shinu
  9. Carlos
    Carlos avatar
    83 posts
    Member since:
    Apr 2013

    Posted 27 Aug 2013 Link to this post

    Hi and thanks,

    What i need its to automatacly remove the invalid file from the list, and the select file option to be showned.

    Best Regards
  10. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 28 Aug 2013 Link to this post

    Hi Carlos,

    When you are selecting multiple files  and If the selected files contains an invalid file, that invalid file also will be listed in the controls uploaded files with a red mark which is the default behavior but internally the valid files are only uploaded to the Temporary Folder and available for upload on the server. In my code what I am doing is I am programmatically removing the invalid file name displayed along with the uploaded files list and displaying an alert. Please elaborate on what you mean by "automatically remove the invalid file". Please note when you are using RadAsyncUpload you cannot programmatically open the "Open File" window. (e.g. when RadAsyncUpload uses a SIlverlight module, the control uses the silverlight object)

    Thanks,
    Shinu.
  11. Carlos
    Carlos avatar
    83 posts
    Member since:
    Apr 2013

    Posted 28 Aug 2013 Link to this post

    Hi,

    I tried you code but the behavior isnt onlçy removing the invalid file also removes de textbox and buton of the select file instruction.

    Thanks
  12. Carlos
    Carlos avatar
    83 posts
    Member since:
    Apr 2013

    Posted 02 Sep 2013 Link to this post

    isn't there a solution
  13. Sharjeel
    Sharjeel avatar
    1 posts
    Member since:
    Sep 2014

    Posted 24 Sep 2014 Link to this post

    Hi guys, 
    same problem here i don't want to show invalid files in list, and I use the following code 
     function validationFailed(radAsyncUpload, args) {
                    var $ = $telerik.$;
                    var $row = $(args.get_row());
                    $telerik.$(".ruCancel").parent().remove();

                 }
    it removes the invalid file message from list but the problem is after reaching its total file count, it hides selection button and the valid files in list is none, so how we tackle show selection button after valid files reach to total count







  14. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 29 Sep 2014 Link to this post

    Hello,

    You can also remove the failed validation files with jQuery as in the code below:
    function validationFailed(sender, eventArgs) {
    sender._updateCancelButton(eventArgs.get_row());
    $telerik.$(".ruRemove", eventArgs.get_row()).click();
    }

    Hope this will be helpful.

    Regards,
    Boyan Dimitrov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

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