This is a migrated thread and some comments may be shown as answers.

Context menu not working with master page

1 Answer 34 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Nabarun asked on 16 Sep 2013, 08:36 AM
Below is my requirement,
Need to attach Rad context Menu on right click in side an text-box control.

I have used context menu example given in

This is working on a normal web page, but when ever I use master page context menu is not working any more. Below is the aspx page code
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="TestPageWithMasterPage.aspx.cs" Inherits="TestPageWithMasterPage" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <telerik:RadContextMenu runat="server" ID="ChooseDesktopImage"
          EnableRoundedCorners="true" EnableShadows="true" OnClientItemClicked="chooseDesktopImageItemClicked">
                        <telerik:ContextMenuElementTarget ElementID="desktop" />
                        <telerik:RadMenuItem Text="Beach" Value="Beach" />
                        <telerik:RadMenuItem Text="Field" Value="Field" />
                        <telerik:RadMenuItem Text="House" Value="House" />
        <asp:TextBox ID="desktop" runat="server"></asp:TextBox>
         <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
          <script type="text/javascript">
              function showingSetAsDesktop(sender, args) {
                  //Disable the setAsDesktop menu on the desktop image
                  if (args.get_targetElement().id == "desktop") {
              function chooseDesktopImageItemClicked(sender, args) {
                  $get("desktop").value = args.get_item().get_value();


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 17 Sep 2013, 09:54 AM
Hi Nabarun,

Note that when using a master page and a content page the id of the controls on the content page changes (here you can read more on this topic) and therefore you get this issue. To get the contextmenu work as expected on your page you can either set the ClientIDMode="Static" property of the TextBox or change the id that you assign to the RadContextMenu so it matches the rendered id:
<asp:TextBox ID="desktop" runat="server" ClientIDMode="Static"></asp:TextBox>

If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question