RadMenu in a User Control

7 posts, 0 answers
  1. neebs
    neebs avatar
    106 posts
    Member since:
    Apr 2007

    Posted 04 Sep 2009 Link to this post

    I have a User Control that contains a RadMenu which I use to populate all forms in a web application. I have the need now to selectively disable menu items based on selecting a tabstrip item. I've done a test by placing a RadMenu directly on a page and setting up the RadAjaxManager to update the control from the tabstrip and the menu is rendered properly, disabled or enabled as the case may be. However the User Control containing my real menu does not show up as a control on the RadAjaxManager Property Builder. Is there something I need to do to the User Control containing the RadMenu to make it visible?


  2. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 08 Sep 2009 Link to this post

    Hello,

    You should add RadAjaxManager control in the main page and RadAjaxManagerProxy inside a WebUserControl. Then configured RadAjaxManagerProxy control the same way as the manager to AJAX-enable the user control(RadMenu).
    Find more information about how to use RadAjaxManager in page -> user control scenario in the following links:
    RadAjax and WebUserControls
    Ajax / User Controls/Master pages

    Greetings,
    Pavlina
    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. UI for ASP.NET Ajax is Ready for VS 2017
  4. neebs
    neebs avatar
    106 posts
    Member since:
    Apr 2007

    Posted 08 Sep 2009 Link to this post

    I'm not able to make this work. I have two instances that are failing. In the first case I need to disable a menu item located in a user control based on which tabstrip tab is selected. In my user control, which contains a RadAjaxManagerProxy and a RadMenu I have a method that looks like this:

        public void SetMenuItemEnabled(string item, bool enabled) 
        { 
            RadMenuItem menuitem = RadMenuWorkflow.FindItemByValue(item); 
            if (menuitem != null
            { 
                menuitem.Enabled = enabled; 
            } 
        } 
     

    The parameter item is the value setting of the menu item. This method is called from the main page whenever the tab is changed as follows:

        private void SetMenuProperties() 
        { 
            switch (mTabPage) 
            { 
                case TabPages.Orders: 
                    MenuBar.SetMenuItemEnabled("Logout"false); 
                    break
                case TabPages.Jobs: 
                    MenuBar.SetMenuItemEnabled("Logout"true); 
                    break
            } 
        } 
     

    where MenuBar is the user control mentioned above. 

    I initially call SetMenuProperties in the Page_Load method of the main page, and it works - Logout is disabled. However when I call it from the TabClick method of the RadTabStrip, it has no effect. 

    I'll post the second issue in a separate post.
  5. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 08 Sep 2009 Link to this post

    Hi Steve,

    Based on the supplied information, it is hard to determine the cause of the problem that you mentioned. If the issue persists, you can open a formal support ticket, and send us a small project, demonstrating the case, for further testing and review.

    Sincerely yours,
    Pavlina
    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.
  6. neebs
    neebs avatar
    106 posts
    Member since:
    Apr 2007

    Posted 08 Sep 2009 Link to this post

    For the second instance, I need to programmatically add menu items to the user control based on which page it resides in. So for a specific page, I execute the following code:

                    RadMenuItem item = MenuBar.AddMenuItem("Jobs""Cancel Selected Jobs""CancelSelectedJobs"); 
                    item = MenuBar.AddMenuItem("Jobs""Accept Selected Jobs""AcceptSelectedJobs"); 
     

    which invokes this method inside the user control:

        public RadMenuItem AddMenuItem(string parent, string text, string value) 
        { 
            RadMenuItem parentitem = RadMenuWorkflow.FindItemByValue(parent); 
            RadMenuItem newitem = null
     
            if (parentitem != null
            { 
                newitem = new RadMenuItem(text); 
                newitem.Value = value; 
                parentitem.Items.Add(newitem); 
            } 
     
            return newitem; 
        } 
     

    This works fine, however in no case am I able to disable these programmatically added menu items from the code-behind in the main page.

    Thanks, Steve
  7. neebs
    neebs avatar
    106 posts
    Member since:
    Apr 2007

    Posted 08 Sep 2009 Link to this post

    OK, I have the functionality I need now, with a workaround. If I remove the RadTabStrip from the RadAjaxManager Controls, forcing a full refresh on tab change then the menu inside the control is rendered properly. This is not the best way, imo, however in this application it is not a big issue, as they tend to stay on a tab page for a long time. As long as I Ajaxify the controls within each PageView, the performance is adequate.
  8. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 09 Sep 2009 Link to this post

    Hello Steve,

    To avoid duplicate posts, we can continue our communication in the other support ticket post that you have opened on the matter. I have already answered your ticket with the same question, but I believe that the attached demo will be of help for our customers that read this thread.

    Sincerely yours,
    Pavlina
    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017