Disable Masterpage Menu from contentPage

Asked

Viewed 577 times

0

I have a small menu on the Master Page:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="INTEGRASYS.SiteMaster" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
    <title> ::INTEGRASYS::</title>
    <link href="~/Styles/estilo.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="HeadContent" runat="server">
    </asp:ContentPlaceHolder>
</head>

<body>
    <form runat="server">
        <header>

                <ul>
                    <li class = "liultimo"><a href = "index.aspx" > ADM SYS </a></li>
                    <li> <a href = "administrativo.aspx" > Administrativo </a></li>
                    <li> <a href = "" > Executivo </a></li>
                    <li> <a href = "" > Comercial </a></li>
                    <li> <a href = "" > Técnico </a></li>
                </ul>
        </header>
. . . 

My home page is login (login.aspx). What I want to do is leave these list items disabled (li) and enable them after the login, on the page index.aspx

The login is already working and redirects to the index.aspx.

  • 1

    If you are saving the user somewhere after login (Session for example), you can put a if in his <ul> in case the Session user’s null, do not display menus.

1 answer

2


One possible solution, is you leave the <li> that will not be displayed within a Panel.

<ul>
    <li class="liultimo"><a href="index.aspx" >ADM SYS</a></li>
    <asp:Panel runat="server" Visible="False" ID="pnlEsconder">
        <li><a href="administrativo.aspx">Administrativo</a></li>
    </asp:Panel>
    <li><a href="">Executivo</a></li>
    <li><a href="">Comercial</a></li>
    <li><a href="">Técnico</a></li>
</ul>

and in the code behind, of Content Page, check that the User is logged in, and display the panel.

var pnlEsconder = (Panel)Master.FindControl("pnlEsconder");
if (Session["logado"] != null) pnlEsconder.Visible = true;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.