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

RadContextMenu with template

7 Answers 340 Views
Menu
This is a migrated thread and some comments may be shown as answers.
kevin yang
Top achievements
Rank 1
kevin yang asked on 03 Mar 2010, 03:08 AM

Hi,

I try to follow RadMenu Template Demo http://demos.telerik.com/aspnet-ajax/menu/examples/functionality/templates/defaultcs.aspx
example.  But instead of using RadMenu, I use RadContextMenu.  The problem I have is I can't get the TextBox control Text in the template.  If I change it back to RadMenu, I am able to see the TextBox control Text.  Can anyone tell me what's the wrong of my code?  or if anyway to get around.  Any suggestion is appreciated.

Here is my code snippet

// Click the image button  to show context menu  
 
<asp:ImageButton ID="ibAdvanced" runat="server" ImageUrl="~/images/icons/16/View.gif" OnClientClick ="showMenu(event)" ImageAlign="AbsMiddle" ToolTip="Advanced Search" />   
 
// Rad Context Menu I defined here with Item Template  
<telerik:RadContextMenu runat="server" ID="rcmSearchMenu" Skin="Vista">    
   <Items>   
      <telerik:RadMenuItem Text="Advanced" CssClass="advSearch" PostBack="false">   
         <ItemTemplate>   
            <asp:ListBox id="lbField" Rows="1" Width="100px" SelectionMode="Single" runat="server">   
               <asp:ListItem> A </asp:ListItem>   
               <asp:ListItem> B </asp:ListItem>   
               <asp:ListItem> C </asp:ListItem>   
            </asp:ListBox>    
            <asp:ListBox id="lbOperator" Rows="1" Width="100px" SelectionMode="Single" runat="server">   
               <asp:ListItem> Greater </asp:ListItem>   
               <asp:ListItem> Less </asp:ListItem>   
            </asp:ListBox>   
            <asp:RequiredFieldValidator ID="rfvAdvSearch" runat="server" ControlToValidate="tbAdvSearch" ValidationGroup="vgAdvSearch" Text="empty*" />   
            <asp:TextBox ID="tbAdvSearch" runat="server" EnableViewState="true" />  
            <asp:LinkButton ID="lkbAdvSearch" runat="server" CssClass="advSearch-button" OnClick="lkbAdvSearch_Click" OnClientClick="searchclick()" ValidationGroup="vgAdvSearch" ToolTip="Click to Search" EnableViewState="true" />   
            <asp:ImageButton ID="ibCancel" runat="server" ImageUrl="~/images/icons/16/Cancel.gif" OnClientClick="hideMenu(event)" ImageAlign="AbsMiddle" ToolTip="Cancel" />   
         </ItemTemplate>   
      </telerik:RadMenuItem>   
   </Items>   
</telerik:RadContextMenu>   
   
 
// the event when user click the Link Button control in template  
 
protected void lkbAdvSearch_Click(object sender, EventArgs e)   
{  
   TextBox AdvSearchTextBox = (TextBox)((LinkButton)sender).NamingContainer.FindControl("tbAdvSearch");   
   ListBox fieldListBox = (ListBox)((LinkButton)sender).NamingContainer.FindControl("lbField");   
   ListBox operatorListBox = (ListBox)((LinkButton)sender).NamingContainer.FindControl("lbOperator");  
 
   // No comiplation, no runtime error  
   // But I am not getting the Text value I enter in Textbox, Also, I am not getting value of ListBox Item I selected either  


Help , please

Thanks

 

7 Answers, 1 is accepted

Sort by
0
kevin yang
Top achievements
Rank 1
answered on 04 Mar 2010, 12:43 AM
Any help from Telerik Support Team?
Thanks
0
Peter
Telerik team
answered on 08 Mar 2010, 04:22 PM
Hi kevin,

We used your code to create a simple test page, but we could not replicate the problem. Please, modify the attached test page so that the problem occurs and send it back to us via a support ticket. Or, let us know what is different in your case.

All the best,
Peter
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
kevin yang
Top achievements
Rank 1
answered on 08 Mar 2010, 11:52 PM
Hi Peter,

Thank you for the reply.
My code is actually in part of master page.
0
kevin yang
Top achievements
Rank 1
answered on 09 Mar 2010, 02:54 AM

Hi Peter

Basically I just rewrite the code by using your attached zip in a very simple web project.
Below is the copy and paste of   Default.aspx, Default.aspx.cs ,  Default.aspx.designer.cs ,  style.css  and images used.
I still can't see the textbox value/text I typed after click the button. 
In the  event   lkbAdvSearch_Click., the Response only writes back "Text in TextBox-" to screen.

Please Advise.

Thank you

====> Default.aspx        
       
       
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Context._Default" %>        
       
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>        
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">        
<html xmlns="http://www.w3.org/1999/xhtml">        
<head id="Head1" runat="server">        
    <title></title>        
    <style type="text/css">        
        .rtbFocused        
        {        
            background: red !important;        
        }        
    </style>        
    <link href="./styles/style.css" rel="stylesheet" type="text/css" />         
</head>        
       
<body>        
    <form id="form1" runat="server">        
    <telerik:RadScriptManager ID="ScriptManager" runat="server">         
    </telerik:RadScriptManager>        
       
    <script type="text/javascript">        
       
        function showMenu(e) {        
            var contextMenu = $find("<%= rcmSearchMenu.ClientID %>");        
       
            if ((!e.relatedTarget) || (!$telerik.isDescendantOrSelf(contextMenu.get_element(), e.relatedTarget))) {        
                contextMenu.show(e);        
            }        
       
            $telerik.cancelRawEvent(e);        
        }        
       
        function hideMenu(e) {        
            var contextMenu = $find("<%= rcmSearchMenu.ClientID %>");        
       
            var mItem = contextMenu.findItemByText("Advanced");        
       
            var ctrol = mItem.findControl("tbAdvSearch");        
            //alert(mItem)        
       
            if ((!e.relatedTarget) || (!$telerik.isDescendantOrSelf(contextMenu.get_element(), e.relatedTarget))) {        
                contextMenu.hide(e);        
            }        
       
            $telerik.cancelRawEvent(e);        
        }                
       
    </script>        
       
    <asp:ImageButton ID="ibAdvanced" runat="server" ImageUrl="~/images/View.gif"       
        OnClientClick="showMenu(event)" ImageAlign="AbsMiddle" ToolTip="Advanced Search" />        
         
    <telerik:RadContextMenu runat="server" ID="rcmSearchMenu" Skin="Vista" CssClass="advSearch-m">        
        <Items>        
            <telerik:RadMenuItem Text="Advanced" CssClass="advSearch" PostBack="false">        
                <ItemTemplate>        
                    <asp:ListBox ID="lbField" Rows="1" Width="100px" SelectionMode="Single" runat="server">        
                        <asp:ListItem> A </asp:ListItem>        
                        <asp:ListItem> B </asp:ListItem>        
                        <asp:ListItem> C </asp:ListItem>        
                    </asp:ListBox>        
                    <asp:ListBox ID="lbOperator" Rows="1" Width="100px" SelectionMode="Single" runat="server">        
                        <asp:ListItem> Greater </asp:ListItem>        
                        <asp:ListItem> Less </asp:ListItem>        
                    </asp:ListBox>        
                    <asp:RequiredFieldValidator ID="rfvAdvSearch" runat="server" ControlToValidate="tbAdvSearch"       
                        ValidationGroup="vgAdvSearch" Text="empty*" />        
                    <asp:TextBox ID="tbAdvSearch" runat="server" EnableViewState="true" />        
                   <asp:LinkButton ID="lkbAdvSearch" runat="server" Text="Advanced Searc" CssClass="advSearch-button"       
                        ValidationGroup="vgAdvSearch" ToolTip="Click to Search"       
                        EnableViewState="true" onclick="lkbAdvSearch_Click" />        
                    <asp:ImageButton ID="ibCancel" runat="server" ImageUrl="~/images/Cancel.gif"       
                         ImageAlign="AbsMiddle" OnClientClick="hideMenu(event)" ToolTip="Cancel" />        
                </ItemTemplate>        
            </telerik:RadMenuItem>        
        </Items>        
    </telerik:RadContextMenu>        
             
    </form>        
</body>        
</html>        
       
       
       
       
==> Default.aspx.cs        
       
using System;        
using System.Collections.Generic;        
using System.Linq;        
using System.Web;        
using System.Web.UI;        
using System.Web.UI.WebControls;        
using System.Data;        
using Telerik.Web.UI;        
       
       
namespace Context        
{        
    public partial class _Default : System.Web.UI.Page        
    {        
        protected void Page_Load(object sender, EventArgs e)        
        {        
       
       
        }        
       
       
        protected void lkbAdvSearch_Click(object sender, EventArgs e)        
        {        
            TextBox AdvSearchTextBox = (TextBox)((LinkButton)sender).NamingContainer.FindControl("tbAdvSearch");        
            ListBox fieldListBox = (ListBox)((LinkButton)sender).NamingContainer.FindControl("lbField");        
            ListBox operatorListBox = (ListBox)((LinkButton)sender).NamingContainer.FindControl("lbOperator");        
       
            Response.Write("Text in TextBox-"+AdvSearchTextBox.Text);        
            // No comiplation, no runtime error        
            // But I am not getting the Text value I enter in Textbox, Also, I am not getting value of ListBox Item I selected either        
       
        }        
    }        
}        
       
       
       
==> Default.aspx.designer.cs        
       
//------------------------------------------------------------------------------        
// <auto-generated>        
//     This code was generated by a tool.        
//     Runtime Version:2.0.50727.3603        
//        
//     Changes to this file may cause incorrect behavior and will be lost if        
//     the code is regenerated.        
// </auto-generated>        
//------------------------------------------------------------------------------        
       
namespace Context {        
            
            
    public partial class _Default {        
                
        /// <summary>        
        /// Head1 control.        
        /// </summary>        
        /// <remarks>        
        /// Auto-generated field.        
        /// To modify move field declaration from designer file to code-behind file.        
        /// </remarks>        
        protected global::System.Web.UI.HtmlControls.HtmlHead Head1;        
                
        /// <summary>        
        /// form1 control.        
        /// </summary>        
        /// <remarks>        
        /// Auto-generated field.        
        /// To modify move field declaration from designer file to code-behind file.        
        /// </remarks>        
        protected global::System.Web.UI.HtmlControls.HtmlForm form1;        
                
        /// <summary>        
        /// ScriptManager control.        
        /// </summary>        
        /// <remarks>        
        /// Auto-generated field.        
        /// To modify move field declaration from designer file to code-behind file.        
        /// </remarks>        
        protected global::Telerik.Web.UI.RadScriptManager ScriptManager;        
                
        /// <summary>        
        /// ibAdvanced control.        
        /// </summary>        
        /// <remarks>        
        /// Auto-generated field.        
        /// To modify move field declaration from designer file to code-behind file.        
        /// </remarks>        
        protected global::System.Web.UI.WebControls.ImageButton ibAdvanced;        
                
        /// <summary>        
        /// rcmSearchMenu control.        
        /// </summary>        
        /// <remarks>        
        /// Auto-generated field.        
        /// To modify move field declaration from designer file to code-behind file.        
        /// </remarks>        
        protected global::Telerik.Web.UI.RadContextMenu rcmSearchMenu;        
    }        
}        
       
      
===> styles.css      
    
    
body     
{     
    font-family: Verdana;     
    font-size: 8pt;     
}     
    
.clearfix:after     
{     
    content: ".";     
    display: block;     
    height: 0;     
    clear: both;     
    visibility: hidden;     
}     
    
.clearfix     
{     
    display: inline-block;     
}     
    
    
div.RadMenu_Vista .rmRootGroup     
{     
    background-color: White !important;     
    border: 1px solid White;     
}     
    
    
div.RadMenu_Vista .rmRootGroup .advSearch-m     
{     
    /*background: transparent url('./Images/icons/16/view.gif') no-repeat 0 0 !important;*/    
    text-decoration: none !important;     
    background-color: White !important;     
    font-size: 10px;     
    color: Blue;     
}     
    
div.RadMenu_Vista .rmRootGroup .advSearch-m:hover     
{     
    /*background: transparent url('./Images/icons/16/view.gif') no-repeat 0 0 !important;*/    
    text-decoration: none !important;     
    background-color: White !important;     
    font-size: 10px;     
    color: Blue;     
}     
    
div.RadMenu_Vista .rmGroup     
{     
    text-decoration: none !important;     
    background-color: White !important;     
}     
    
    
div.RadMenu_Vista .rmGroup li.advSearch     
{     
    text-decoration: none !important;     
    background: transparent url('images/Cancel.gif');     
    background-color: White !important;     
    width: 600px;     
    font-size: 10px;     
}     
    
    
div.RadMenu_Vista .rmGroup a.advSearch-button     
{     
    display:inline-block;     
    background: transparent url('images/login.png') no-repeat 0 0;     
}     
   

0
kevin yang
Top achievements
Rank 1
answered on 10 Mar 2010, 12:39 AM
Anyone?
0
Peter
Telerik team
answered on 11 Mar 2010, 06:19 PM
Hi kevin,

We still cannot replicate the problem locally. To be able to give you a specific solution we will need a simple working demo project which we can run without modification and test locally.

Cheers,
Peter
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
kevin yang
Top achievements
Rank 1
answered on 11 Mar 2010, 07:14 PM
Hi Peter,

I don't seem to be able to attach a zip file here.
I send a "General Feedback" in support with my attched zip has my demo solution.
Let me know if you are able to get it or how I can pass the zip to you

Thanks
Tags
Menu
Asked by
kevin yang
Top achievements
Rank 1
Answers by
kevin yang
Top achievements
Rank 1
Peter
Telerik team
Share this question
or