put security to dropdown menu

fernando salaburu 21 Reputation points
2021-07-09T01:11:50.203+00:00

good!! I have a drop down menu

 <div id="topnav">  
      <ul>  
        <li class="active"><a href="PageLogin.aspx">Acceso</a></li>  
        <li><a href="#" >Style Demo</a></li>  
        <li><a href="#">Full Width</a></li>  
        <li><a href="#">Seguridad</a>  
          <ul>  
            <li><a href="PageAltaEmpleado.aspx">Alta de Usuario</a></li>  
            <li><a href="PageBuscaUsuario.aspx">Busca Usuarios</a></li>  
            <li><a href="PagePuertas.aspx">Puertas ABM</a></li>  
            <li><a href="PageAdmPuertas.aspx">Administra Puerta</a></li>  
            <li><a href="PageUsuarios.aspx">prueba</a></li>  
            <li><a href="PageAccesos.aspx">Administra Accesos</a></li>  
            <li><a href="PageAutocompletado.aspx">Autocompletado </a></li>  
            <li><a href="#">Link 8</a></li>  
            <li><a href="#">Link 9</a></li>  
            <li><a href="#">Link 10</a></li>  
            <li><a href="#">Link 11</a></li>  
            <li><a href="#">Link 12</a></li>  
            <li><a href="#">Link 13</a></li>  
  
          </ul>  
        </li>  
        <li class="last" ><a href="#">A Long Link Text</a></li>  
          <asp:Label ID="MuestraFecha" runat="server"></asp:Label>  
      </ul>  
    </div>  
  

by SQL I bring the security of the doors that the user can see

DataTable access = (DataTable)Session["MyAccess"];  

return this result

113049-image.png

I would like to know if the item (<li> <a href="#"> Link 8 </a> </li>) can be given the code (example 2055) and then buy it with what I bring from the database and I save it in the session variable, and then this line, remove it, enable, disable, with javascript or somehow ???

de esta manera el usuario no podra acceder a esa linea del menu desplegable o no la ve.

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,288 questions
{count} votes

1 answer

Sort by: Most helpful
  1. fernando salaburu 21 Reputation points
    2021-07-10T14:30:27.463+00:00

    there I found a solution

    in the drop-down menu I put

    <div id="topnav">
          <ul>
            <li class="active"><a href="#">Home</a></li>
            <li><a id="A2047" runat="server" href="WebForm2.aspx">PUERTAS</a></li>
            <li><a id="A2048" runat="server" href="#">URUARIO</a></li>
            <li><a id="A2049" runat="server" href="#">SEGURIDAD</a>
              <ul>
                <li><a id="A2050" runat="server" href="#">Link 1</a></li>
                <li><a id="A2051" runat="server" href="#">Link 2</a></li>
                <li><a id="A2052" runat="server" href="#">Link 3</a></li>
              </ul>
    

    then the code looked for the menu item and took it out

    Page_Load

                A2047.Visible = false;
                A2048.Visible = false;
                A2049.Visible = false;
    

    then with the accesses that the user can see, I visualize them

     DataTable access = (DataTable)Session["MyAccess"];
    
    //esto recorre la tabla (Datatable) 
    
                for (int i = 0; i < access.Rows.Count; i++)
                {
                    string door = access.Rows[i]["D_NO"].ToString();
    
                    if (door == "2049")
                    {
                        A2049.Visible = true;
    
                    }
                 }
    

    or it can also be done by Css

     //A2049.Attributes["class"] = "yourCssClass"; 
    
    0 comments No comments