Context menu not working with master page

2 posts, 0 answers
  1. Nabarun
    Nabarun avatar
    2 posts
    Member since:
    Apr 2013

    Posted 16 Sep 2013 Link to this post

    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();

  2. Kate
    Kate avatar
    1898 posts

    Posted 17 Sep 2013 Link to this post

    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.
Back to Top