RadMenu Click event not fired inside RadTab

5 posts, 0 answers
  1. sudhakar
    sudhakar avatar
    35 posts
    Member since:
    Jul 2010

    Posted 21 Jul 2010 Link to this post

    Hello Telerik Team,

    Please help, i am struggling to find the click event fired on any of the menus. No matter what i do the event is not fired.
    The menus are inside the tab. tried creating the object and using "FinditembyText"  but not working....

    Please look for below code.  and
    if at all someone can give me solution for this
    *********************
    Start Aspx Code
    **********************
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <telerik:RadTabStrip ID="RadTabStrip1" runat="server" Skin="Office2007">   
                <Tabs>  
                     <telerik:RadTab runat="server" Text="Root RadTab2">   
                         <Tabs>  
                             <telerik:RadTab runat="server" Text="Child RadTab 1">   
                             <TabTemplate>  
                                <telerik:RadMenu ID="RadMenu2" runat="server" Skin="Office2007" OnItemClick="RadMenu1_ItemClick" OnItemDataBound="RadMenu1_ItemDataBound">
                                    <CollapseAnimation Duration="200" Type="OutQuint" />  
                                     <Items>  
                                         <telerik:RadMenuItem Text="SomeMenuTest" >   
                                             <Items>  
                                                 <telerik:RadMenuItem Text="Test1" NavigateUrl="http://www.google.com" />  
                                                 <telerik:RadMenuItem Text="Test2" NavigateUrl="http://www.yahoo.com"/>  
                                                 <telerik:RadMenuItem Text="Test3"  NavigateUrl="http://www.dbs.com"/>  
                                                 <telerik:RadMenuItem Text="Test4"  NavigateUrl="http://www.asia1.com"/>  
                                             </Items>  
                                         </telerik:RadMenuItem>  
                                     </Items>  
                                 </telerik:RadMenu>  
                             </TabTemplate>  
                             </telerik:RadTab>  
                             <telerik:RadTab runat="server" Text="Child RadTab 2">   
                             </telerik:RadTab>  
                         </Tabs>  
                     </telerik:RadTab>  
                       
                 </Tabs>  
             </telerik:RadTabStrip>  
        </form>
    *********************
    End Aspx Code
    **********************
      
    *********************
    Codebehind
    *********************
      
    protected void RadMenu1_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e)
        {
            Response.Redirect(e.Item.Attributes["NavigateUrl"].ToString());
        }
      
       protected void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e)
       {
           e.Item.Attributes["NavigateUrl"] = e.Item.NavigateUrl;
           e.Item.NavigateUrl = "";
       }
  2. Yana
    Admin
    Yana avatar
    5025 posts

    Posted 22 Jul 2010 Link to this post

    Hello sudhakar,

    Please check this help article for more information about this issue.

    All the best,
    Yana
    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
  3. sudhakar
    sudhakar avatar
    35 posts
    Member since:
    Jul 2010

    Posted 22 Jul 2010 Link to this post

    Hello Yana,

    Thankyou for the reply. But if you see the code the RadMenu is inside the Radtab, becuase of which it doesn't get fired.

    As a normal way if i copy the example you have given, it works but as soon as i put a tab above the same example it will not fire the event .. Jut try with RadTab.

    Any help will be appreciated.

    Regards
    Sudhakar
  4. Yana
    Admin
    Yana avatar
    5025 posts

    Posted 27 Jul 2010 Link to this post

    Hello sudhakar,

    The problem with your code is that ItemDataBound event is not fired at all - generally this event is fired only when the menu is databound, so the items still have NavigateUrl set. You can work-around it like this:

    <telerik:RadTabStrip ID="RadTabStrip1" runat="server" Skin="Office2007" SelectedIndex="0">
        <Tabs>
            <telerik:RadTab runat="server" Text="Root RadTab2" Selected="True" SelectedIndex="0">
                <Tabs>
                    <telerik:RadTab runat="server" Text="Child RadTab 1" Value="tabWithMenu" Selected="True">
                        <TabTemplate>
                            <telerik:RadMenu ID="RadMenu2" runat="server" Skin="Office2007" OnItemClick="RadMenu1_ItemClick"
                                OnItemDataBound="RadMenu1_ItemDataBound">
                                <CollapseAnimation Duration="200" Type="OutQuint" />
                                <Items>
                                    <telerik:RadMenuItem Text="SomeMenuTest">
                                        <Items>
                                            <telerik:RadMenuItem Text="Test1" />
                                            <telerik:RadMenuItem Text="Test2" NavigateUrl="http://www.yahoo.com" />
                                            <telerik:RadMenuItem Text="Test3" NavigateUrl="http://www.dbs.com" />
                                            <telerik:RadMenuItem Text="Test4" NavigateUrl="http://www.asia1.com" />
                                        </Items>
                                    </telerik:RadMenuItem>
                                </Items>
                            </telerik:RadMenu>
                        </TabTemplate>
                    </telerik:RadTab>
                    <telerik:RadTab runat="server" Text="Child RadTab 2">
                    </telerik:RadTab>
                </Tabs>
            </telerik:RadTab>
        </Tabs>
    </telerik:RadTabStrip>

    and then find the menu in Page_Load event:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            RadMenu menu = (RadMenu)RadTabStrip1.FindTabByValue("tabWithMenu").FindControl("RadMenu2");
            foreach (RadMenuItem item in menu.GetAllItems())
            {
                if (item.NavigateUrl != "")
                {
                    item.Attributes["NavigateUrl"] = item.NavigateUrl;
                    item.NavigateUrl = "";
                }
            }
        }
    }

    Hope this helps.

    All the best,
    Yana
    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
  5. sudhakar
    sudhakar avatar
    35 posts
    Member since:
    Jul 2010

    Posted 29 Jul 2010 Link to this post

    Hello Yana,

    Thankyou for the reply and given code.
    It works...!!!

    Regards
    Sudhakar
Back to Top