Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Updated 14-Feb-13 0:36am
v2
Comments
Bandi Ramesh 14-Feb-13 5:35am    
Posting the code may resolve your problem

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.
C#
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.
 
Share this answer
 
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
VB
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,

VB
If Session("userrole") = "Admin" Then
    Master.menustate("Manager")
   
Else
    Master.menustate("Agent")

End If
 
Share this answer
 
v2

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