This is a migrated thread and some comments may be shown as answers.

disable specific menu item on form load

1 Answer 40 Views
Menu
This is a migrated thread and some comments may be shown as answers.
JJ
Top achievements
Rank 1
JJ asked on 13 Jul 2010, 04:41 PM

I load radmenu from sitemap, now i like to disable one manu item - "ADMIN" on form load.
I tried the following code, but menuitem always returns null so it can never be disable.

RadMenuItem menuitem = mainMenu.FindItemByValue("ADMIN");  
if (menuitem != null)

 

{

menuitem.Enabled =

false;  

 

 

  

}
What i did wrong?
Thanks

 

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
JJ
Top achievements
Rank 1
answered on 13 Jul 2010, 05:43 PM

 

private void DisableItemsFromText(string texttodisable)
{
    var items = mainMenu.GetAllItems();
    int total_items = items.Count;
    for (int i = 0; i < total_items; i++)
    {
        if (items[i].Text.ToUpper()== texttodisable)
        {
            items[i].Enabled = false;
            items[i].NavigateUrl = "";
        }
    }
}
The above code works for me
Tags
Menu
Asked by
JJ
Top achievements
Rank 1
Answers by
JJ
Top achievements
Rank 1
Share this question
or