Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

Menu / Context Menu

wallpaper
Right Click to Select Desktop: Beach Field House

  • Note: To run in Opera Browser RadContextMenu needs right-clicks allowed. This is done by using "Tools -> Preferences -> Advanced -> JavaScript options -> Allow script to receive right clicks". In addition, because of browser limitations, on right-click both RadContextMenu and the standard browser context menu are displayed. A workaround to the latter is using the ESC key to hide the default browser context menu.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="c#" CodeFile="DefaultCS.aspx.cs" AutoEventWireup="true" Inherits="Telerik.Web.Examples.Menu.ContextMenu.Default.DefaultCS" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:HeadTag ID="Headtag1" runat="server" />
        <link rel="stylesheet" type="text/css" href="styles.css" />
    </head>
    <body class="BODY">

        <script type="text/javascript">
                function showingSetAsDesktop(sender, args)
                {
                    //Disable the setAsDesktop menu on the desktop image
                    if (args.get_targetElement().id == "qsfexDesktop")
                    {
                        args.set_cancel(true);
                    }
                }

                function setAsDesktopItemClicked(sender, args)
                {
                    var menuItemValue = args.get_item().get_value();
                    if (menuItemValue == "SetAsDesktop")
                    {
                        var targetElement = args.get_targetElement();
                        if (targetElement)
                        {
                            $get("qsfexDesktop").src = targetElement.src.replace("Thumb.gif", ".jpg");
                        }
                    }
                    else if (menuItemValue == "OpenInNewWindow")
                    {
                        window.radopen(args.get_targetElement().src.replace("Thumb.gif", ".jpg"));
                    }
                }

                function chooseDesktopImageItemClicked(sender, args)
                {
                    $get("qsfexDesktop").src = args.get_item().get_value();
                }
        </script>

        <form id="mainForm" method="post" runat="server">
            <telerik:RadScriptManager ID="ScriptManager" runat="server" />
            <telerik:RadWindowManager runat="Server" ID="RadWindowManager1" />
            <telerik:RadContextMenu ID="SetAsDesktop" runat="server"
             EnableRoundedCorners="true" EnableShadows="true"
             OnClientShowing="showingSetAsDesktop" OnClientItemClicked="setAsDesktopItemClicked">
                <Targets>
                    <telerik:ContextMenuTagNameTarget TagName="img" />
                </Targets>
                <Items>
                    <telerik:RadMenuItem Text="Set as desktop" Value="SetAsDesktop" />
                    <telerik:RadMenuItem Text="Open in a new window" Value="OpenInNewWindow" />
                </Items>
            </telerik:RadContextMenu>
            <telerik:RadContextMenu ID="ChooseDesktopImage" runat="server"
                EnableRoundedCorners="true" EnableShadows="true"
                OnClientItemClicked="chooseDesktopImageItemClicked">
                <Targets>
                    <telerik:ContextMenuElementTarget ElementID="qsfexDesktop" />
                </Targets>
                <Items>
                    <telerik:RadMenuItem Text="Beach" Value="./Images/beach.jpg" />
                    <telerik:RadMenuItem Text="Field" Value="./Images/field.jpg" />
                    <telerik:RadMenuItem Text="House" Value="./Images/house.jpg" />
                </Items>
            </telerik:RadContextMenu>
            <qsf:Header ID="Header1" runat="server" NavigationLanguage="C#" />
            <div id="qsfexDesktopContainer">
                <img id="qsfexDesktop" src="./Images/beach.jpg" alt="wallpaper" width="316" height="252" />
            </div>
            <div id="qsfexWallpaperPool">
                <span>Right Click to Select Desktop:</span>
                <img src="./Images/beachThumb.gif" alt="Beach" width="121" height="56" />
                <img src="./Images/fieldThumb.gif" alt="Field" width="121" height="56" />
                <img src="./Images/houseThumb.gif" alt="House" width="121" height="56" />
            </div>

            <qsf:Footer ID="Footer1" runat="server" />
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451