validate asyncupload

3 posts, 1 answers
  1. Shawn
    Shawn avatar
    14 posts
    Member since:
    Dec 2012

    Posted 28 Feb 2013 Link to this post

    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. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 01 Mar 2013 Link to this post

    Hi,

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

    Thanks,
    Princy
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shawn
    Shawn avatar
    14 posts
    Member since:
    Dec 2012

    Posted 01 Mar 2013 Link to this post

    Thank you.  That took care of the issue.  Have a great day.

    Shawn
Back to Top