Click here to Skip to main content
11,648,094 members (62,278 online)
Rate this: bad
good
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 5:53am
Rate this: bad
good
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.
  Permalink  
Comments
Mukunda Raj at 29-Dec-11 12:02pm
   
Could you please explain me where should i pull menu items(which method) and how??
Espen Harlinn at 30-Dec-11 6:37am
   
Right, good advice
Rate this: bad
good
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
  Permalink  
Rate this: bad
good
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;
            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;
        }
  Permalink  
Comments
Mark Nischalke at 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
0 jyo.net 500
1 F-ES Sitecore 370
2 DamithSL 300
3 OriginalGriff 277
4 CPallini 250
0 OriginalGriff 1,342
1 jyo.net 994
2 DamithSL 981
3 Sergey Alexandrovich Kryukov 893
4 CPallini 845


Advertise | Privacy | Mobile
Web01 | 2.8.150804.4 | 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