How to hide the menu based on user
< asp:Menu id="Menu1" runat="server" width="200px" >< Items >
< asp:MenuItem Text="EMPLOYEE DETAILS" NavigateUrl="~/Employee_Details.aspx"
Value="Employee_Details" >
< /asp:MenuItem >
<asp:MenuItem Text="HR" NavigateUrl="~/HR.aspx" Value="HR">
<asp:MenuItem Text="Manager" NavigateUrl="~/manager.aspx" Value="Manager">
i want to hide the HR and Manager menu once user login show the Employee menu and remove the HR and Manager menu.
Note once user login it will redirect to Home page. home.aspx
in home.aspx all the menu name are visible.
i tried the below code once user login in to home page shows the Employee menu only and remove the HR and Manager menu.
In Login page i written the below code as follows
if (txtuser.Text == "admin")
{
var menu = Page.Master.FindControl("Menu1") as Menu;
if (menu != null)
{
menu.Items.Remove(menu.FindItem("Attendance"));
menu.Items.Remove(menu.FindItem("Manager"));
}
}
from the above code i am removing the Attendance and HR menu.
but when user login the home.aspx all the menus are displaying Employee ,Attendance and Manager.
what is the mistake in my above code.