Open a dialog on ContextMenu item click

22 Mar 20221 minute to read

This section explains about how to open a dialog on ContextMenu item click. This can be achieved by handling dialog open in select event of the ContextMenu.

In the following sample, Dialog will open while clicking Save As... item:

<div id="contextmenutarget">Right click/Touch hold to open the ContextMenu </div>
@Html.EJS().Dialog("dialog").Header("Save As").Content("This file can be saved as PDF").Width("250px").Visible(false).Buttons(ViewBag.DialogButtons).Render()

    function dlgButtonClick() {
        ej.base.getComponent(document.getElementById('dialog'), "dialog").hide();

    function itemSelect() {
        ej.base.getComponent(document.getElementById('dialog'), "dialog").show();


#contextmenutarget {
    border: 1px dashed;
    height: 250px;
    padding: 10px;
    position: relative;
    text-align: center;
    color: gray;
    line-height: 17;
    font-size: 14px;

public ActionResult DialogButton()
    ViewBag.DialogButtons = new
                isPrimary = true,
                cssClass = "e-flat",
                content = "Submit",
                click = "dlgButtonClick"
    return View();