Open a dialog on ContextMenu item click

22 Mar 20222 minutes 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>
<ejs-contextmenu id="contextmenu" target="#contextmenutarget" items="@ViewBag.menuItems" select="itemSelect"></ejs-contextmenu>
<ejs-dialog id="dialog" content="This file can be saved as PDF" visible="false" position='@new Syncfusion.EJ2.Popups.DialogPositionData() { X= "100" , Y= "100" }' target="#contextmenutarget" width="200px" height="110px">
        <e-dialog-dialogbutton buttonModel="@ViewBag.DialogButtons" click="dlgButtonClick"></e-dialog-dialogbutton>

    function dlgButtonClick() {
        var dialogObj = ej.base.getInstance(document.getElementById('dialog'), ejs.popups.Dialog);

    function itemSelect() {
        var dialog = ej.base.getInstance(document.getElementById('dialog'), ejs.popups.Dialog);;

    #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();