How to prevent file delete from onclientdeleting event

5 posts, 0 answers
  1. chandrasekhar
    chandrasekhar avatar
    9 posts
    Member since:
    Oct 2010

    Posted 21 Oct 2010 Link to this post

    Hi,
    i want to prevent file deletion on click of "Cancel" from confirmation alert

    <telerik:RadAsyncUpload ID="radUpload" runat="server" OnClientValidationFailed="validationFailed" TemporaryFileExpiration="5"        OnClientFileSelected="fileSelected" OnClientDeleting="fileDelete" OnClientFileUploaded ="fileUploaded">
    </telerik:RadAsyncUpload>

    function fileDelete(sender, args) {
         
            if (confirm("Are you sure to Delete the record?"))  {
                args._cancel = false;       
            }
            else {
                args.set_cancel(true);        
                //args._cancel = true;
                //sender._cancelEvent();
            }
        }

    How to prevent file deletion on click of "Cancel" button.

    On click of "Cancel" it is not not deleting from row, but actually file is deleted from control. So on click of Cancel button i want to prevent the file delete from control also.

    Thanks,
    Chandra.T

  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 22 Oct 2010 Link to this post

    Hi chandrasekhar,

    I've managed to get this working using the following code:

        <script type="text/javascript">
            function fileDeleting(sender, args) {
                if(!confirm("Are you sure that you want to delete the file?"))
                    args.set_cancel(true);
            }
         
        </script>
     
            <telerik:RadAsyncUpload runat="server"
                ID="RadAsyncUpload1"
                AllowedFileExtensions="jpeg,jpg,png"
                OnClientDeleting="fileDeleting">
             
            </telerik:RadAsyncUpload>


    Greetings,
    Genady Sergeev
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. chandrasekhar
    chandrasekhar avatar
    9 posts
    Member since:
    Oct 2010

    Posted 22 Oct 2010 Link to this post

    Hi Genady Sergeev,
    Thanks for your reply.

    On click of "x Remove" i am displaying confirmation alert with "OK" and "Cancel".
    If you click OK or Cancel, surely the file will be deleted from upload control; but The only difference is if you click "Cancel" that file will not be delete from UI but internally in control the file will be deleted.

    Note: Upload two files; and click on "x Remove" for one file; click on "Cancel".
    Still you are able to see two files; but if you check the files count in code behind you will get file count 1. not 2.
    (radUpload.UploadedFiles.Count)
    Because once user clicks on "x Remove" the file will be deletes.
    With Cancel only we can prevent the display;
    But i want to prevent both display and file delete on click of "Cancel"

    Help me....

    Thanks,
    Chandrasekhar.T
  4. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 27 Oct 2010 Link to this post

    Hi chandrasekhar,

    Thank you for pointing this problem to us. Please use the following JavaScript in order to workaround the problem. You need to paste it right after the ScriptManager declaration:

    Telerik.Web.UI.RadAsyncUpload.prototype.deleteFileInputAt = function(index, skipEvent) {
            var row = $telerik.$(this._getRow(index));
                 
                if (!Telerik.Web.UI.RadAsyncUpload.callBaseMethod(this, 'deleteFileInputAt', [index, skipEvent]))
                    return;
                     
                var fileInfo = row.data('fileInfo');
                Array.remove(this._uploadedFiles, fileInfo);
                this.updateClientState();
     
                this._uploadModule.rowRemoved(row);
     
                var shouldAddInput = row.parent().children().has('.ruFakeInput').length == 0;
     
     
     
                if (shouldAddInput && this._autoAddFileInputs)
                    this.addFileInput();
            }

    Also, I've updated your telerik points for the report.

    Regards,
    Genady Sergeev
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  5. markhugy
    markhugy avatar
    1 posts
    Member since:
    Nov 2010

    Posted 02 Dec 2010 Link to this post

    Here is a good tool to find and delete duplicate files
    www.duplicateFilesDeleter.com
Back to Top