getUploadedFiles not found

7 posts, 1 answers
  1. support
    support avatar
    10 posts
    Member since:
    Aug 2010

    Posted 30 Dec 2010 Link to this post

    I'm have created a custom validator for the RadAsyncUpload control on my form however I'm getting a javascript error that the getUploadedFiles() method doesn't exist for this object. Below is the code I've used

    <asp:CustomValidator ID="rfvFileUpload" ClientValidationFunction="validateFileUpload" runat="server" ErrorMessage="File Required" />

    function validateFileUpload(sender, args) {
        var uploadObject = $find("<%= RadAsyncUpload1.ClientID %>");
        args.IsValid = uploadObject.getUploadedFiles().length != 0;
    }

    I'm using the Telerik RadControls for ASP.NET AJAX Q2 2010


    Regards,
    Victor
  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 05 Jan 2011 Link to this post

    Hello support,

    We have added the getUploadedFiles method for the Q3 release of RadAsyncUpload. Should you need to  use it with earlier versions, you can add it to the RadAsyncUpload using the following code:

    Telerik.Web.UI.RadAsyncUpload.prototype.getUploadedFiles: function() {
                var files = [];
     
                $telerik.$(".ruUploadSuccess", this.get_element()).each(function(index, value) {
                    files[index] = value;
                });
     
                return files;
            }

    place that code after the ScriptManager declaration.

    Kind regards,
    Genady Sergeev
    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.
  3. support
    support avatar
    10 posts
    Member since:
    Aug 2010

    Posted 10 Jan 2011 Link to this post

    Thanks for the workaround but I'm not sure what you meant by placing the piece of code after the ScriptManager declaration.

    Do you mean like this? 
    <form id="form1" runat="server" defaultbutton="btnSearch">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" LoadScriptsBeforeUI="true" ScriptMode="release" EnablePartialRendering="true" />
         
        <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
            <script type="text/javascript">
                Telerik.Web.UI.RadAsyncUpload.prototype.getUploadedFiles: function() {
                    var files = [];
          
                    $telerik.$(".ruUploadSuccess", this.get_element()).each(function(index, value) {
                        files[index] = value;
                    });
          
                    return files;
                }
            </script>
        </telerik:RadScriptBlock>

    If so I'm getting a javascript error 

    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; Media Center PC 6.0; InfoPath.2; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E)
    Timestamp: Tue, 11 Jan 2011 01:58:15 UTC

    Message: Expected ';'
    Line: 73
    Char: 61
    Code: 0
    URI: http://localhost:57445/intranet.UI/home.aspx

    Regards,
    Victor
  4. Answer
    Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 12 Jan 2011 Link to this post

    Hello support,
    <form id="form1" runat="server" defaultbutton="btnSearch">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" LoadScriptsBeforeUI="true" ScriptMode="release" EnablePartialRendering="true" />
          
        <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
            <script type="text/javascript">
                Telerik.Web.UI.RadAsyncUpload.prototype.getUploadedFiles = function() {
                    var files = [];
           
                    $telerik.$(".ruUploadSuccess", this.get_element()).each(function(index, value) {
                        files[index] = value;
                    });
           
                    return files;
                }
            </script>
        </telerik:RadScriptBlock>


    Please excuse me, I've given you incorrect code. Here is the correct one:



    Greetings,
    Genady Sergeev
    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.
  5. support
    support avatar
    10 posts
    Member since:
    Aug 2010

    Posted 14 Jan 2011 Link to this post

    I've got a slight problem but we're almost there. When my page loads the RadAsyncUpload control is invisible. The code snippet that you've provided requires the control to be visible otherwise it throws this error: 'Telerik.Web.UI.RadAsyncUpload.prototype' is null or not an object
  6. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 17 Jan 2011 Link to this post

    Hello support,

    Indeed, this is true, in order to add functions to the RadAsyncUpload prototype the latter should be visible on the page. Thank you for clarifying this.

    All the best,
    Genady Sergeev
    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.
  7. support
    support avatar
    10 posts
    Member since:
    Aug 2010

    Posted 17 Jan 2011 Link to this post

    Thanks for the help Genady. I guess I'll have to find a work around in the UI design to allow the RadAsyncUpload control to be visible when the form is initially loaded.
Back to Top