We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Contextmenu on an image


I'm wondering how to add a leftclick contextmenu on an asp image element?

Øyvind Knappskog Olsen
Norconsult Informasjonssystemer AS

1 Reply

ES Ezhil S Syncfusion Team March 20, 2015 11:49 AM UTC

Hi Øyvind,

Thank you for contacting Syncfusion support.

Currently we haven’t provided in built property to enable context menu on left click. So that we suggest you to bind the click event for the image element and in the click event display the context menu. Using the show() method pass the X and Y coordinate of the mouse pointer along with the corresponding target element to display the ContextMenu on left click. Please refer the following code snippet,



<img src="Content/snowfall.jpg" width="300" height="300" runat="server" id="menutarget" />

<ej:Menu ID="Menu1" MenuType="ContextMenu" runat="server" ContextMenuTarget="#menutarget">


<ej:MenuItem Text="Cut"></ej:MenuItem>



<ej:MenuItem Text="Copy"></ej:MenuItem>



<ej:MenuItem Text="Paste"></ej:MenuItem>



<ej:MenuItem SpriteCssClass="separator"></ej:MenuItem>



<ej:MenuItem Text="Comments"></ej:MenuItem>



<ej:MenuItem Text="Links"></ej:MenuItem>



<ej:MenuItem Text="Clear Formatting"></ej:MenuItem>




<script type="text/javascript">

$("#<%=menutarget.ClientID%>").click(function () {

var menuobj = $("ul#<%=Menu1.ClientID%>").data("ejMenu");

menuobj.show(event.clientX, event.clientY, "#<%=menutarget.ClientID%>", "click"); // code to display the menu on left click




Please let us know if you have any other queries.


Ezhil S

Live Chat Icon For mobile
Up arrow icon