Click here to Skip to main content
11,933,037 members (53,213 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 29-Dec-11 6:53am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
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
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

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
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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:

public void DisplayMenuTabs()
            if (Session["Menu1Access"].ToString() == "True")
                Menu1.Visible = true;
                Menu1.Visible = false;
            if (Session["Menu2Access"].ToString() == "True")
                Menu2.Visible = true;
                Menu2.Visible = false;
            if (Session["Menu3Access"].ToString() == "True")
                Menu3.Visible = true;
                Menu3.Visible = false;
Mark Nischalke 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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.151126.1 | Last Updated 30 Dec 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100