onmenuitemclick event not firing when menu items loaded dynamically

2 posts, 0 answers
  1. Rick
    Rick avatar
    1 posts
    Member since:
    Dec 2011

    Posted 21 Mar 2012 Link to this post

    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;
    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";
        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";

    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?

  2. Bozhidar
    Bozhidar avatar
    1096 posts

    Posted 22 Mar 2012 Link to this post

    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,
    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.
  3. DevCraft R3 2016 release webinar banner
Back to Top