This is a migrated thread and some comments may be shown as answers.

RadAsyncUpload and test

12 Answers 279 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Carlos
Top achievements
Rank 1
Carlos asked on 22 Aug 2013, 03:18 PM
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

12 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 Aug 2013, 04:11 AM
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.
0
Carlos
Top achievements
Rank 1
answered on 23 Aug 2013, 08:42 AM
Hi all, Thansk

and in C#.

Regards.
0
Carlos
Top achievements
Rank 1
answered on 23 Aug 2013, 03:41 PM
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
0
Shinu
Top achievements
Rank 2
answered on 26 Aug 2013, 12:22 PM
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.
0
Carlos
Top achievements
Rank 1
answered on 26 Aug 2013, 02:08 PM
Hi and thanks,

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

Best regards
0
Shinu
Top achievements
Rank 2
answered on 27 Aug 2013, 05:04 AM
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
0
Carlos
Top achievements
Rank 1
answered on 27 Aug 2013, 10:45 AM
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
0
Shinu
Top achievements
Rank 2
answered on 28 Aug 2013, 05:53 AM
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.
0
Carlos
Top achievements
Rank 1
answered on 28 Aug 2013, 08:33 AM
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
0
Carlos
Top achievements
Rank 1
answered on 02 Sep 2013, 10:37 AM
isn't there a solution
0
Sharjeel
Top achievements
Rank 1
answered on 24 Sep 2014, 11:22 AM
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







0
Boyan Dimitrov
Telerik team
answered on 29 Sep 2014, 11:05 AM
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.

 
Tags
AsyncUpload
Asked by
Carlos
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Carlos
Top achievements
Rank 1
Sharjeel
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or