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

Client validation message

1 Answer 161 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
sunny
Top achievements
Rank 1
sunny asked on 22 Jun 2011, 01:43 AM
Hello there.

I am trying to get separate client validation messages for AsyncUpload depending upon whether it was a fail due to filesize or extention type.

At the moment i can only get a generic message using :

 function validationFailed(sender, eventArgs) {
              
            //var RadProgressArea1 = $('#<%= RadProgressArea1.ClientID %>');
//             $.each(sender, function(i, n) {
//                            alert("Name: " + i + ", Value: " + n);
//                        });    
            $("#errorHolder").append("<p>Validation failed for '" + eventArgs.get_fileName() + "'.</p>").fadeIn("slow");
        }

I want seperate messages for those two cases.

i have also tried to not specify maxfilesize in asyncupload and catch filesize error in 

function ClientProgressUpdating(sender, args)  {
           
           if(args.get_data().fileSize > 3145728)
           {                          
                sender.deleteFileInputAt(0);
                  $("#errorHolder").append("<p>file size if more than max for '" + eventArgs.get_fileName() + "'.</p>").fadeIn("slow");
//                if(confirm("Are you sure"))
//                {
//                   //validationFailed(sender, args);
//                   return false;
//                     $("#errorHolder").append("<p>Validation failed for '" + eventArgs.get_fileName() + "'.</p>").fadeIn("slow");
//                }
               
           }
//            
        }

it stops the fileupload but hangs at the screen where the progress bar is not moving forward and doesnt set the error message label

Thank you for helping.

1 Answer, 1 is accepted

Sort by
0
Peter Filipov
Telerik team
answered on 24 Jun 2011, 12:30 PM
Hi sunny,

Please review the below code:

<form id="form1" runat="server">
   <div>
       <telerik:RadScriptManager runat="server" ID="RadScriptManager">
       </telerik:RadScriptManager>
       <telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1" OnClientValidationFailed="onClientValidationFailed"
           MaxFileSize="1024000" AllowedFileExtensions="jpg">
       </telerik:RadAsyncUpload>
 </div>
   </form>
   <script type="text/javascript">
       function onClientValidationFailed(sender, args) {
           var upload = $find("<%= RadAsyncUpload1.ClientID %>");
           if (upload.isExtensionValid(args.get_fileName())) {
               alert("File size is exceeded!");
           }
           else {
               alert("File type is different than allowed!")
           }
       }
   </script>


Best wishes,
Peter Filipov
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
AsyncUpload
Asked by
sunny
Top achievements
Rank 1
Answers by
Peter Filipov
Telerik team
Share this question
or