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

Hello

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

Regards
Ø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,

<code>

[ASPX]

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

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

<Items>

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

</Items>

<Items>

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

</Items>

<Items>

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

</Items>

<Items>

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

</Items>

<Items>

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

</Items>

<Items>

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

</Items>

<Items>

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

</Items>

</ej:Menu>

[Script]

<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

});

</script>

</code>

Please let us know if you have any other queries.

Regards,

Ezhil S


Loader.
Live Chat Icon For mobile
Up arrow icon