Search results

Add confirm dialog to remove the files

You can customize the uploader control using confirm dialog before removing the files. Here, ej2 dialog is used as confirm dialog. Refer to the following example.

tagHelper
confirm-dialog.cs
index.css
@{
    var asyncSettings = new Syncfusion.EJ2.Inputs.UploaderAsyncSettings { SaveUrl = "https://aspnetmvc.syncfusion.com/services/api/uploadbox/Save", RemoveUrl = "https://aspnetmvc.syncfusion.com/services/api/uploadbox/Remove" };
}
<div class="control_wrapper">
    <ejs-uploader id="UploadFiles" removing="onremove" asyncSettings="@asyncSettings">
    </ejs-uploader>
    <ejs-dialog id="dialog" target="body" visible="false" width="250px" content="Confirm to remove the file?">
        <e-dialog-buttons>
            <e-dialog-dialogbutton buttonModel="ViewBag.button" click="Close"></e-dialog-dialogbutton>
            <e-dialog-dialogbutton buttonModel="ViewBag.button1" click="onClick"></e-dialog-dialogbutton>
        </e-dialog-buttons>
    </ejs-dialog>

</div>
<script>
    var removeFile = [], dialog;

    window.onload = function () {
        dialog = document.getElementById("dialog").ej2_instances[0];
    }

    function onremove(args) {
        emoveFile = [];
        args.cancel = true;
        removeFile.push(args.filesData);
        dialog.show();
    }

    function onClick(args) {
        var uploadObj = document.getElementById("UploadFiles").ej2_instances[0];
        dialog.hide();
        uploadObj.remove(removeFile[0], false, true);
    }

    function Close() {
        dialog.hide();
    }
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace EJ2CoreSampleBrowser.Controllers.TextBoxes
{
    public partial class UploaderController : Controller
    {
        public ActionResult DefaultFunctionalities()
        {
            ViewBag.button = new
            {
                content = "Cancel",
                isPrimary = true
            };

            ViewBag.button1 = new
            {
                content = "Ok",
                isPrimary = true
            };
            
            return View();
        }
    }
}
.control_wrapper {
    max-width: 400px;
    margin: 0 auto;
}