Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
i have designed a master page in the left side i have menu items as logout, time sheets,reports,manage users. if the associate login into this site he should able to see the menu item except reports how to hide.
for example there are two types of users:
 
manager
user
 
manager have the access to view, edit and add the new users
but user is havign access to see his own record and reports. so in my design i used menu in the left side there are options like logout,manage users, reports, time sheets.
if user logged in to the site he should be able to see the options in menu like logout,reports. how can we hide other items in menu for the specified login.
Posted 13-Feb-13 22:58pm
Edited 14-Feb-13 0:36am
v2
Comments
bandi.ramesh at 14-Feb-13 5:35am
   
Posting the code may resolve your problem
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Instead of Hide and Show etc, I would prefer creating the menu item dynamically using code something like below which is based on the User during the time of login.
if (blIsAssociate)
            {
                MenuItem miNewItem = new MenuItem();
                int intMenuItemIndex = 1;
                miNewItem.Text = "Reports";
                miNewItem.Value = "Reports";
                miNewItem.NavigateUrl = "~/somepage.aspx";
                Menu1.Items.AddAt(intMenuItemIndex ,miNewItem);
            }
 
Hope this helps!
 
Please post your code or logic for better, precise answers.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I had done something like the below.
Add this part into the MasterPage that has the main menu control
Make sure that in the start there is only one menu tab which is visible to all.
then dynamically add the menu nodes and the page that it relates to
Public Sub menustate(mstate As String)
    If mstate = "Manager" Then
        Dim newme As New MenuItem
        newme.Text = "Admin"
        newme.Value = "Admin"
        newme.NavigateUrl = "~/adminpage.aspx"
        NavigationMenu.Items.AddAt(1, newme)
        NavigationMenu.Items.Item(1).Selectable = True
 
    Else 
        'NavigationMenu.Items.Item(1).Text = ""
        'NavigationMenu.Items.Item(1).Value = ""
        'NavigationMenu.Items.Item(1).Selectable = False
    End If
End Sub
 
In the child page after authentication,
 
If Session("userrole") = "Admin" Then
    Master.menustate("Manager")
   
Else
    Master.menustate("Agent")
 
End If
  Permalink  
v2

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 305
1 _Amy 235
2 Peter Leow 205
3 Andreas Gieriet 180
4 Dave Kreskowiak 130
0 OriginalGriff 7,540
1 Sergey Alexandrovich Kryukov 6,412
2 Maciej Los 3,849
3 Peter Leow 3,653
4 CHill60 2,712


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 14 Feb 2013
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