You must Sign In to post a response.
  • Category: .NET

    Hide menu is not working in asp.net page

    i want to hide the HR menu once user login into the login page.

    Once user logged in it will redirect to Employee.aspx page

    In Employee.aspx page all menus are visible.

    I want to hide the HR menu in Employee.aspx page.

    I written my code as follows to hide the HR menu in Employee.aspx page

    i written my below code in login.aspx.cs page My code as follows


    if (txtuser.Text == "admin")
    {
    string url = HttpContext.Current.Request.Url.AbsoluteUri;
    if (url == "http://localhost:65742/HRMS/Employee.aspx")
    {
    Menu mainMenu = (Menu)Page.Master.FindControl("Menu1");
    mainMenu.Items.Remove(mainMenu.FindItem("HR"));
    mainMenu.Visible = false;
    }
    }

    but when i run the above code in Employee.aspx page HR Menu is not visible false.

    from my above code what is the mistake.

    Please let me know.
  • #769666
    i think postback is causing and hence again rebinding all menu items it seems. try to keep menu construction logic
    If(!IsPostBack){ }

    also, try to bind the menus on page load event of employee.aspx but not from the master page load.

    Thanks!
    B.Ramana Reddy


  • Sign In to post your comments