ItemClick issue

3 posts, 0 answers
  1. Emmanuel Herrera
    Emmanuel Herrera avatar
    2 posts
    Member since:
    Jan 2010

    Posted 20 Jan 2010 Link to this post

    I'm creating dynamic menus, but itemclick event just is not fired, i has been reading doc and says NavigateUrl prevents postback but I'm not even using NavigateUrl, i did a little easy test page and the problem persist:

    using System; 
    using System.Data; 
    using System.Configuration; 
    using System.Web; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using System.Web.UI.WebControls.WebParts; 
    using System.Web.UI.HtmlControls; 
    using Telerik.Web.UI; 
     
    public partial class _Default : System.Web.UI.Page  
        protected void Page_Load(object sender, EventArgs e) 
        { 
     
        } 
        RadMenu menu = new RadMenu(); 
     
        protected void Page_Init(object sender, EventArgs e) 
        { 
            menu.ItemCreated += new RadMenuEventHandler(menu_ItemCreated); 
        } 
     
        protected override void CreateChildControls() 
        { 
            base.CreateChildControls(); 
            //RadMenu menu = new RadMenu(); 
            menu.ID = "radmenucontrol"
            menu.LoadXml("<Menu><Group Flow='Horizontal'><Item  Text='opc1' /><Item  Text='opc2' /></Group></Menu>"); 
     
            menu.ItemClick += new RadMenuEventHandler(menu_ItemClick); 
            this.Controls.Add(menu); 
     
        } 
     
        void menu_ItemCreated(object sender, RadMenuEventArgs e) 
        { 
            e.Item.Attributes["NavigateUrl"] = e.Item.NavigateUrl; 
            e.Item.NavigateUrl = ""
     
        } 
     
        void menu_ItemClick(object sender, RadMenuEventArgs e) 
        { 
            Response.Write("Item Clicked"); 
              
        } 
     

    I tried the ItemCreated event setting NavigateUrl to empty string (just in case) but no succes, i dont know what im doing wrong, any help will be appreciated.




  2. Yana
    Admin
    Yana avatar
    4850 posts

    Posted 22 Jan 2010 Link to this post

    Hi Emmanuel,

    The menu should be placed inside <form> tag in order to work properly,  so modify your code like this:

    form1.Controls.Add(menu);

    Best regards,
    Yana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Emmanuel Herrera
    Emmanuel Herrera avatar
    2 posts
    Member since:
    Jan 2010

    Posted 22 Jan 2010 Link to this post

    Thank you, solved
Back to Top