This is a migrated thread and some comments may be shown as answers.
validate asyncupload
2 Answers 27 Views
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 1
Shawn asked on 28 Feb 2013, 11:25 PM
How can I add validation to my asyncupload control for the current version of Telerick Q3 2012 SP1?  I've tried the following but it is not working with the current version.  I very well could be doing something wrong.  Any thoughts on how to make this work?  Here is the code that I'm using, followed by the error I'm getting.  I'm in VS 2012 and using DotNet 4.5.

<script type="text/javascript">
    Telerik.Web.UI.RadAsyncUpload.prototype.getUploadedFiles = function() {
        var files = [];
 
        $telerik.$(".ruUploadSuccess", this.get_element()).each(function(index, value) {
            files[index] = $telerik.$(value).text();
        });
 
        return files;
    }
 
    function validateUpload(sender, args) {
        var upload = $("RadAsyncUpload1");
        args.IsValid = upload.getUploadedFiles().length != 0;
    }
 
</script>

<asp:CustomValidator runat="server" ID="CustomValidator" ClientValidationFunction="validateUpload"
        ErrorMessage="Select at least a single file">
    </asp:CustomValidator>



Here is the error:

Microsoft JScript runtime error:  Object doesn't support this property or method.

Thanks,

shawn

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 01 Mar 2013, 07:09 AM
Hi,

Try the following javascript.
JS:
function validateUpload(sender, args) {
    var upload = $find("<%= RadAsyncUpload1.ClientID %>")
    args.IsValid = upload.getUploadedFiles().length != 0;
}

Thanks,
Princy
0
Shawn
Top achievements
Rank 1
answered on 01 Mar 2013, 02:20 PM
Thank you.  That took care of the issue.  Have a great day.

Shawn
Asked by
Shawn
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Shawn
Top achievements
Rank 1
Share this question
or