Client-Side programming with RadAsyncUpload

4 posts, 0 answers
  1. ELTON
    ELTON avatar
    2 posts
    Member since:
    Nov 2011

    Posted 12 May 2014 Link to this post

    May I use client-side api to set  MultipleFileSelection, AllowedFileExtensions, MaxFileSize  ??
  2. Aneliya Petkova
    Admin
    Aneliya Petkova avatar
    207 posts

    Posted 14 May 2014 Link to this post

    Hi Elton,

    You can change the allowed file extensions of the RadAsyncUpload on the client using set_allowedFileExtensions property:
    var upload = $find('RadAsyncUpload1');
    upload.set_allowedFileExtensions(".msi,.gif")

    RadAsyncUpload has no client-side properties for MultipleFileSelection and MaxFileSize.

    Regards,
    Aneliya Petkova
    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. upasana
    upasana avatar
    3 posts
    Member since:
    Nov 2015

    Posted 10 Dec 2015 in reply to Aneliya Petkova Link to this post

    Hello Team,

    var upload = $find('RadAsyncUpload1');
    upload.set_allowedFileExtensions(".msi,.gif")

    its not working for me its giving error on setting the extension.

    Here is my code:-

    function OnClientValidationFailed(sender, args) {
       debugger
            var $row = $(args.get_row());
            var erorMessage = getErrorMessage(sender, args);
            if (erorMessage != undefined) {
                var span = createError(erorMessage);
                $row.addClass("ruError");
                $row.append(span);
            }
          
        }

        function getErrorMessage(sender, args) {
        debugger
            var fileExtention = args.get_fileName().substring(args.get_fileName().lastIndexOf('.') + 1, args.get_fileName().length);
            if (args.get_fileName().lastIndexOf('.') != -1) {//this checks if the extension is correct
                   if(fileExtention.indexOf('F')!=0){
                    return ("Invalid file type");
                }
            }
            else {
                return ("not correct extension.");
            }
        }

        function createError(erorMessage) {
        debugger
            var input = '<span class="ruErrorMessage">' + erorMessage + ' </span>';
            return input;
        }

      function OnClientFileUploading(sender, args) {
        debugger
            var fileExtention = args.get_fileName().substring(args.get_fileName().lastIndexOf('.') + 1, args.get_fileName().length);
            var upload =("FileUpload");
            upload.set_allowedFileExtensions("." + fileExtention);
        }

    <telerik:RadAsyncUpload ID="FileUpload" runat="server" OnFileUploaded="Upload_FileUploaded"  OnClientValidationFailed="OnClientValidationFailed" OnClientFileUploading="OnClientFileUploading">
    </telerik:RadAsyncUpload>

    The extension which I want to  set is dynamic like 354647.F01,977543.F08 only "F" will be common in the extension.so i m not able to set it through "AllowedFilesExtensions" property.

    And "OnClientValidationFailed" property is not working with setting "AllowedFilesExtensions" property.

    so please help me this. or suggest me  if there is any other way to do this.

    Please reply ASAP.

  5. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 15 Dec 2015 Link to this post

    Hello Upasana,

    The js error you are getting is because of the following line in your OnClientFileUploading handler:
    var upload =("FileUpload");

    It has to be changed as follows, so that the "upload" variable holds a reference to the AsyncUpload object:
    var upload = $find("FileUpload");
    or
    var upload = sender;

    Regards,
    Ivan Danchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top