Click here to Skip to main content
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 6: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 Marcin Kozub 265
1 Richard MacCutchan 239
2 OriginalGriff 208
3 Sergey Alexandrovich Kryukov 185
4 Praneet Nadkar 167
0 OriginalGriff 7,913
1 Sergey Alexandrovich Kryukov 7,232
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,865


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 30 Dec 2011
Copyright © CodeProject, 1999-2014
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