Click here to Skip to main content
16,022,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using the Menu control in master page to display a menu, How can i disable some particular menu items at runtime?



2-- I have different users, for each user login some particular menu item should be disabled, where and how can i set the items to be disabled?
Posted

Take a look at Jeff Prosises' The SQL Site Map Provider You've Been Waiting For[^]

This shows one way to implement Johns suggestion.

You can use the sitemap as a datasource for your menu.

Best resgards
Espen Harlinn
 
Share this answer
 
You can add Menu Control in the master page, & fetch the menu permission from the DB for the signed in user.
e.g if I were to have 3 menu control in my master page, I fetch the Menu access from the DB and saving it to the session:

C#
public void DisplayMenuTabs()
        {
            if (Session["Menu1Access"].ToString() == "True")
                Menu1.Visible = true;
            else
                Menu1.Visible = false;
            if (Session["Menu2Access"].ToString() == "True")
                Menu2.Visible = true;
            else
                Menu2.Visible = false;
            if (Session["Menu3Access"].ToString() == "True")
                Menu3.Visible = true;
            else
                Menu3.Visible = false;
        }
 
Share this answer
 
Comments
[no name] 29-Dec-11 15:07pm    
Not a very efficient or performant method. There are better ways to do things then beat it with a hammer.
Stroe the menu items in a database and when you populate the menu, only pull menu items from the database that the user has the correct role for.
 
Share this answer
 
Comments
Mukunda Raj 29-Dec-11 12:02pm    
Could you please explain me where should i pull menu items(which method) and how??
Espen Harlinn 30-Dec-11 6:37am    
Right, good advice

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900