Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > RibbonBar > onmenuitemclick event not firing when menu items loaded dynamically

Not answered onmenuitemclick event not firing when menu items loaded dynamically

Feed from this thread
  • Rick avatar

    Posted on Mar 21, 2012 (permalink)

    I am trying to load Menu Items Dynamically in the preRender event based on user permissions.
    if (_UserInfo.ProvPrivInd)
    {
        RibbonBarMenuItem rbmiAddProject = new RibbonBarMenuItem();
        rbmiAddProject.Text = Resources.Hub.EntMgmt_Ribbon_ActionMenu_NewEntProj_Text;
        rbmiAddProject.ImageUrl = "~/Images/Add-New-Folder.png";
        rbmiAddProject.Font.Size = FontUnit.Small;
        rbmiAddProject.Value = "NewEntProject";
        rbmiAddProject.Enabled = true;
         rbmEnterpriseActionMenu.Items.Add(rbmiAddProject);
    }
    if (!_UserInfo.ECAExecInd || _UserInfo.ECAAdminInd || _UserInfo.RRDAdminInd)
    {
        RibbonBarMenuItem rbmiAddUesr = new RibbonBarMenuItem();
        rbmiAddUesr.Text = Resources.Hub.EntMgmt_Ribbon_ActionMenu_AddUsersMultiProj_Text;
        rbmiAddUesr.ImageUrl = "~/Images/Change-Group.png";
        rbmiAddUesr.Font.Size = FontUnit.Small;
        rbmiAddUesr.Value = "AddUsersMultiProj";
        rbmEnterpriseActionMenu.Items.Add(rbmiAddUesr);
        RibbonBarMenuItem rbmiRemoveUesr = new RibbonBarMenuItem();
        rbmiRemoveUesr.Text = Resources.Hub.EntMgmt_Ribbon_ActionMenu_RemUsersMultiProj_Text;
        rbmiRemoveUesr.ImageUrl = "~/Images/Delete-User.png";
        rbmiRemoveUesr.Font.Size = FontUnit.Small;
        rbmiRemoveUesr.Value = "RemUsersMultiProj";
        rbmEnterpriseActionMenu.Items.Add(rbmiRemoveUesr);
    }

    But when I click on the item in the browser a post back occurs but the onmenuitemclick event isn't handled.  
    I get a javascript error on the page.

    *********************************
    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; .NET4.0E; Tablet PC 2.0)
    Timestamp: Wed, 21 Mar 2012 16:54:29 UTC

    Message: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
    Line: 6
    Char: 62099
    Code: 0
    ************************************

    any ideas?

    Reply

  • Bozhidar Bozhidar admin's avatar

    Posted on Mar 22, 2012 (permalink)

    Hi Rick,

    When adding items to the RibbonBar, you should use the Page_Init event, since RadRibbonBar doesn't use ViewState, and any controls added after this event, are lost upon postback and cannot be recreated in time for them to work properly.
     
    All the best,
    Bozhidar
    the Telerik team
    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 their blog feed now.

    Reply

  • Say Hello to Telerik's PivotGrid for ASP.NET AJAX, Silverlight, WPF and WinForms. Now packed with OLAP support.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > RibbonBar > onmenuitemclick event not firing when menu items loaded dynamically
Related resources for "onmenuitemclick event not firing when menu items loaded dynamically"

ASP.NET RibbonBar Features  |  Documentation  |  Demos  |  Step-by-step Tutorial  ]