Context Menu in ASP.NET MVC FileExplorer

13 Jun 20239 minutes to read

The context-menu has list of items which helps to perform FileExplorer operations, and it appears based on the target such as file or folder.

Context menu items

The below table shows the context menu items corresponding to the location where it is opened:

Context menu location Context menu items Screenshot
While right click on tree view nodes (from navigation pane)

* New folder
* Upload
* Delete
* Rename
* Cut
* Copy
* Paste
*Get info

While right click on File / Folder

* Open
* Download
* Upload
* Delete
* Rename
* Cut
* Copy
* Paste
* Get info
*Open folder location

While right click on layout (content pane)

* Refresh
* Paste
* Sort by
* New folder
* Upload 
* Get info 

The below table explains the behavior of each context menu item:


It opens the selected folder. When an image file selected it opens the preview of the image. For the remaining files this option becomes disabled.


It downloads the selected file. When a file or number of files selected at that time only download option enabled.

If multiple files selected then it downloads all the files in a zip format.


It makes the copy of the selected files or folders into the clipboard. When the user paste the files in any location, the files are removed from the source location.


It makes the copy of the selected files or folders into the clipboard. When the user paste the files, the copy of the files only pasted in the target location.


It paste the files from the clipboard into the current selected folder. Note that when the files are copied into the clipboard at that time only it enabled.


It deletes the current selected file or folder. When you select any file or folder at that time only this option gets enabled.

If multiple files selected then it deletes all the selected items.


This is used to rename the current selected file or folder. When you select any file or folder at that time only this option gets enabled.

Even multiple files selected it renames the single file only.

New Folder

It creates a new folder on the current directory.

While click on the “NewFolder” item a dialog appears to get the folder name. Based on the user input, a new folder create on the current directory.


It uploads a file or list of files into the current directory.

Get info

It displays the details of the current selected file or folder.

Sort By

It's used to sorting the files and folders from the current directory.The sorting can be done based on the columns available from grid,in both ascending and descending order.

Open folder location It helps to open a file location from the filtered list.

Context menu Visibility

The presence of the context menu can be controlled by the “ShowContextMenu” property. This was enabled by default, and by disabling this property you can prevent our built-in context menu.

In the view page, add FileExplorer helper and specify the context menu visibility as false.

  • @(Html.EJ().FileExplorer("fileExplorer")

    Enable / Disable the Context menu Item

    The context menu items can be enabled or disabled through the client side public methods. It enables or disables the item from all the context menu where it is present.

    For example, if you disable the “Upload” item, it disables in all places wherever it appears such as open the context menu on “TreeView”, open on file/folder, and open on layout.

    These methods only accepts the context menu item name as the parameter.

  • $(function () {
                    var fileExpObj = $("#fileExplorer").data("ejFileExplorer");
                    // this disables the New Folder item
                    fileExpObj.disableMenuItem("New folder");
                    // this disables the Download item

    Context Menu Customization

    You can customize the ContextMenu of FileExplorer control by using ContextMenuSettings property.

    You can add your own context menu items and its action along with default context menu items of FileExplorer control. You can also remove the default context menu items in FileExplorer control.

    To add/remove/re-arrange context menu items, you need to use ContextMenuSettings.items property and to bind required actions for newly added menu items and add sub menu items, use ContextMenuSettings.CustomMenuFields property.

    Add the following code example to the corresponding controller page.

  • C#
  • public ActionResult FileActionContextMenu(FileExplorerParams args)
        FileExplorerOperations operation = new FileExplorerOperations();
        switch (args.ActionType)
            case "Read":
                return Json(operation.Read(args.Path, args.ExtensionsAllow));
            case "CreateFolder":
                return Json(operation.CreateFolder(args.Path, args.Name));
            case "Paste":
                return Json(operation.Paste(args.LocationFrom, args.LocationTo, args.Names, args.Action, args.CommonFiles));
            case "Remove":
                return Json(operation.Remove(args.Names, args.Path));
            case "Rename":
                return Json(operation.Rename(args.Path, args.Name, args.NewName, args.CommonFiles));
            case "GetDetails":
                return Json(operation.GetDetails(args.Path, args.Names));
            case "Download":
                operation.Download(args.Path, args.Names);
            case "Upload":
                operation.Upload(args.FileUpload, args.Path);
            case "Search":
                return Json(operation.Search(args.Path, args.ExtensionsAllow, args.SearchString, args.CaseSensitive));
        return Json("");

    In the view page, add FileExplorer helper and specify the ContextMenuSettings property.

  • @* removed the "NewFolder" item from NavigationPane ContextMenu *@
    @{List<String> navigationBar = new List<string>() { "Upload", "|", "Delete", "Rename", "|", "Cut", "Copy", "Paste", "|", "Getinfo" }; }
    @* added the custom ContextMenu item (View) to Current working directory ContextMenu *@
    @{List<String> cwd = new List<string>() { "Refresh", "Paste", "|", "SortBy", "View", "|", "NewFolder", "Upload", "|", "Getinfo" };}
    @* removed "Upload" item from Selected files/ folder's ContextMenu *@
    @{List<String> files = new List<string>() { "Open", "Download", "|", "Delete", "Rename", "|", "Cut", "Copy", "Paste", "|", 
            "OpenFolderLocation", "Getinfo" }; }
        settings => settings.Items(
            item => item.Navbar(navigationBar).Cwd(cwd).Files(files)
        ).CustomMenuFields(fields =>
            fields.Add().Id("View").Text("View by").SpriteCssClass("custom-grid").Child(child =>
                child.Add().Id("tile").Text("Tile view").Action("onLayout");
                child.Add().Id("grid").Text("Grid view").Action("onLayout");
                child.Add().Id("largeIcons").Text("Large icons view").Action("onLayout");
        e => e.MenuOpen("onMenuOpen").LayoutChange("onLayoutChange")

    Icons of context menu items can be customized by overriding the default context menu item style. The following code example illustrates how to customize the icon of context menu items.

  • CSS
  • <style>
        .fe-context-menu .custom-grid:before {
            content: "\e7b9";
        .fe-context-menu .custom-largeIcons:before {
            content: "\e7bb";
        .fe-context-menu .custom-tile:before {
            content: "\e7be";

    The following screenshot displays the customization of context menu in FileExplorer control.

    ASP.NET MVC FileExplorer Customization

    Context Menu Events

    You would be notified with events when you try to open the context menu items (MenuBeforeOpen), after context menu items is opened (MenuOpen) and when you click the menu items (MenuClick). The following code example illustrates how to define those events.

  • @Html.EJ().FileExplorer("fileExplorer").Path("~/FileExplorerContent/").AjaxAction(@Url.Content("FileActionContextMenu")).ClientSideEvents(e => e.MenuBeforeOpen("menuBeforeOpen").MenuOpen("menuOpen").MenuClick("menuClick"))
  • JS
  • function menuBeforeOpen(args) {
        //you add/remove the context menu items in run time
        //do your custom action here.
    function menuOpen(args) {
        //you can also identify which context menu is opened by 
        if (args.contextMenu == "cwd") {
            //do your custom action here.
    function menuClick(args) {
        switch (args.text) {
            case "largeIcons":
                //do your custom action here.