Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am adding my custom menu under site action menu of SharePoint 2010. I have written below code.

  protected override void CreateChildControls()
    {           
        try
        {          
            foreach (Menu LobjMenu in this.Menus)
            {
                SubMenuTemplate LobjMenuTemplate = new SubMenuTemplate();                    
                LobjMenuTemplate.Text = LobjMenu.Title;
                LobjMenuTemplate.Description = LobjMenu.Description;
                LobjMenuTemplate.ImageUrl = LobjMenu.ImageUrl;                    
                LobjMenuTemplate.Sequence = 100000;                          
                foreach (SubMenu LobjSubMenu in LobjMenu.SubMenuItems)
                {
                    Microsoft.SharePoint.WebControls.MenuItemTemplate LobjSubMenuItem = new MenuItemTemplate();
                    LobjSubMenuItem.Text = LobjSubMenu.Title;
                    LobjSubMenuItem.Description = LobjSubMenu.Description;
                    LobjSubMenuItem.ImageUrl = LobjSubMenu.ImageUrl;
                    LobjSubMenuItem.ClientOnClickNavigateUrl = PrepareUrl(LobjSubMenu.ActionUrl);
                    LobjMenuTemplate.Controls.Add(LobjSubMenuItem);                  
                }
                Controls.Add(LobjMenuTemplate);                      
            }
        }
        catch (Exception ex)
        {

        }
    }

This code works goods and adds menu under site action, but there is only way to add click events to sub menu only. There is way to add click event to MenuItemTemplate not for SubMenuTemplate. Does anybody know how to add click events to SubMenuTemplate.

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.