Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Menu > How can I enable/disable Menu Items at Runtime?

Answered How can I enable/disable Menu Items at Runtime?

Feed from this thread
  • Posted on Jan 16, 2012 (permalink)

    I would like to be able to access any menu item at runtime and based on certain logic be able to enable or disable or make it hide. What's the best way to identify each menu item at runtime? How do we give it an ID or some way to identify each one?

    Reading form another post from three years ago, it was suggested to use Sitemap Datasource. Is there a better available now?
    If we have to use the Sitemap Datasource (using XMLProvider the default), how can we use the icons that we have now at design time?

    Thank you in advance!

    Reply

  • Kate Kate admin's avatar

    Posted on Jan 16, 2012 (permalink)

    Hello Ben,

    You can use any of the properties described in the Accessing Items help article in order to find a RadMenuItem at runtime.

    Considering your other questions:
    Reading form another post from three years ago, it was suggested to use Sitemap Datasource. Is there a better available now?If we have to use the Sitemap Datasource (using XMLProvider the default), how can we use the icons that we have now at design time?

    Can you elaborate on your scenario - why you need to use Sitemap Datasource, what you need to do with the icons at design time?

    Greetings,
    Kate
    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

  • Posted on Jan 16, 2012 (permalink)

    Hi Kate;

    Thank you for prompt response. The link you provided is a great value and I had missed it. I will look into it more today and If I have any questions, I'll follow up.

    Can you elaborate on your scenario - why you need to use Sitemap Datasource, what you need to do with the icons at design time?

    Sure! I'm working on an application that I have already created all my menus using Telerik Menu and each item has a nice Icon. I'm happy with this setup. However, when a user is NOT logged in (Not Authenticated), I need to either hide or disable some menu items and only show items for anonymous users. And when a user is Logged in, I need to do reverse, showing some items and hide others.
    So, I was looking at the forum and saw this post where Paul from Telerik suggested to use SiteMapDataSource. Here But this involves in changing my menus and going a different direction. Also, when I was looking at the demos that menu Items come from DataBase or XML, none of them showed Icons. And that was my other question. "IF" I have to go through the SiteMapDataSource and connect it to Telerik Menu, how can I also display icon with each menu item, like I'm doing now?

    So, what's your suggestion as far as direction and be able to control the menu items at runtime?

    Thank you in advance!

    Reply

  • Kate Kate admin's avatar

    Posted on Jan 19, 2012 (permalink)

    Hi Ben,

    Thank you for clarifying. Here I have prepared a simple example how you can use SiteMapDataSource in a combination with RaMenu and images. Using the demonstrated approach you can handle your logic in the ItemDataBound event handler of the RadMenu.

    Kind regards,
    Kate
    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
    Attached files

    Reply

  • Posted on Jan 19, 2012 (permalink)

    Hi kate;

    Thank you for taking the time and preparing the sample. I'll go through it later on. But, do you think based on my need, do I even need to use SiteMapDataSource, or can I just do the filtering with the existing structure of the menu and it's items.

    What's the general rule of just filtering Menu Items (let's say by text) v.s. going through the Sitemap and doing filtering on the datasource?

    Thanks!

    Reply

  • Answer Kate Kate admin's avatar

    Posted on Jan 21, 2012 (permalink)

    Hi Ben,

    In general you can use either of the two approaches depending on your preferences. In the forum that you pointed out, Paul suggested using SiteMapDataSource due to its security trimming feature that will facilitate the "filtering" issue (you will not need to hardcode your logic as much as you would probably need when not using the SiteMapDataSource). However, if you are more comfortable implementing your own "filtering" of the menu items depending of the different users of your system you could skip the SiteMapDataSource binding and implement your preferred data binding.

    All the best,
    Kate
    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

  • Posted on Jan 21, 2012 (permalink)

    Thanks Kate;

    Yes, for "this" case which there are multiple variable involved, besides security, it's actually easier to do it in the code than using SitMap. But your explanation made it easier for me to reach that decision.
    Thank you!

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Menu > How can I enable/disable Menu Items at Runtime?
Related resources for "How can I enable/disable Menu Items at Runtime?"

[  ASP.NET Menu Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]