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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Contextmenu on an image

Thread ID:

Created:

Updated:

Platform:

Replies:

118567 Mar 19,2015 08:59 AM UTC Mar 20,2015 11:49 AM UTC ASP.NET Web Forms 1
loading
Tags: Menu
Øyvind Knappskog Olsen
Asked On March 19, 2015 08:59 AM UTC

Hello

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

Regards
Øyvind Knappskog Olsen
Norconsult Informasjonssystemer AS

Ezhil S [Syncfusion]
Replied On 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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;