Disable menu item after accessing page

2 posts, 0 answers
  1. Menashay
    Menashay avatar
    8 posts
    Member since:
    Jul 2012

    Posted 31 Dec 2013 Link to this post

    I have a kendo menu on the _LoginPartial page.
    The menu has 'links' to various actions for instance:
        .Items(items =>
        .Text("Manage Clients")
       .Action("Index", "Clients")
    ... and so forth

    This menu is showing if the account is authenticated.
    So that users do not keep clicking on the same menu item after they got into their desired page I want to  disable the relevant menu item.
    In the above mentioned example after users click 'manage clients' the action ("Index", "Clients") will be disabled; when users get out of that page
    ('manage clients') that same menu item will be enabled again.
    How can I accomplish this?
  2. Dimo
    Dimo avatar
    8318 posts

    Posted 02 Jan 2014 Link to this post

    Hello Menashay,

    You can add an Enabled() property to each Menu item, which depends on a boolean parameter based on the current controller and view names. Those can be passed from the Controller, e.g. in the ViewBag, or retrieved from the ViewContext / HttpContext.


       .Action("Index", "Home")
       .Enabled(ViewBag.ControllerName != "Home" || ViewBag.ActionName != "Index");

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top