Click here to Skip to main content
12,998,483 members (117,706 online)
Rate this:
Please Sign up or sign in to vote.
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 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
Updated 14-Feb-13 0:36am
bandi.ramesh 14-Feb-13 5:35am
Posting the code may resolve your problem
Rate this: bad
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.
Rate this: bad
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
        '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
End If

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.170622.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2017
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