Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. How to disable or enable the html li of UI menu or child menu based on user level condition in ASP.net.

How to disable or enable the html li of UI menu or child menu based on user level condition in ASP.net.

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharphtmlasp-netdesigntutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sr159
    wrote on last edited by
    #1

    Hi

    I am using following html code to display menu.
    <ul id="coolMenu">
    <li><a href="#">Master</a>
    <ul class="noJS">
    <li><a href="a.aspx">Category</a></li>
    <li><a href="b.aspx">Subjects</a></li>
    <li><a href="c.aspx">Book Register</a></li>
    <li><a href="d.aspx">Staff Profile</a></li>
    </ul>
    </li>
    <li>
    <a href="#">Transaction</a>
    <ul class="noJS">
    <li><a href="Issues.aspx">Issues</a></li>
    </ul>
    </li>
    <li><a href="#">Reports</a>
    <ul class="noJS">
    <li><a href="e.aspx">Bookswise Report</a></li>
    <li><a href="f.aspx">Stock Report</a></li>
    </ul>
    </li>
    <li><a href="#">Utilities</a>
    <ul class="noJS">
    <li><a href="SignUp.aspx">User SignUp</a></li>
    </ul>
    </li>
    <li><a href="Logout.aspx">Logout</a></li>
    </ul>

    But i want to disable or enable the menu or child menu based on user level condition. How to do this. If anybody knows, please reply me. for ex: if user 2 means i have disable master & Utilities, if user is 1 means i have to enable all menus

    R 1 Reply Last reply
    0
    • S sr159

      Hi

      I am using following html code to display menu.
      <ul id="coolMenu">
      <li><a href="#">Master</a>
      <ul class="noJS">
      <li><a href="a.aspx">Category</a></li>
      <li><a href="b.aspx">Subjects</a></li>
      <li><a href="c.aspx">Book Register</a></li>
      <li><a href="d.aspx">Staff Profile</a></li>
      </ul>
      </li>
      <li>
      <a href="#">Transaction</a>
      <ul class="noJS">
      <li><a href="Issues.aspx">Issues</a></li>
      </ul>
      </li>
      <li><a href="#">Reports</a>
      <ul class="noJS">
      <li><a href="e.aspx">Bookswise Report</a></li>
      <li><a href="f.aspx">Stock Report</a></li>
      </ul>
      </li>
      <li><a href="#">Utilities</a>
      <ul class="noJS">
      <li><a href="SignUp.aspx">User SignUp</a></li>
      </ul>
      </li>
      <li><a href="Logout.aspx">Logout</a></li>
      </ul>

      But i want to disable or enable the menu or child menu based on user level condition. How to do this. If anybody knows, please reply me. for ex: if user 2 means i have disable master & Utilities, if user is 1 means i have to enable all menus

      R Offline
      R Offline
      R Giskard Reventlov
      wrote on last edited by
      #2

      One way to do this would be from code behind. The first thing you would need to do is to make the menu options into server controls. Either replace with, for instance, asp:Hyperlink or add ID="unique_name_for_control" and runat="server" to each link and then, from the OnLoad event determine the user rights and then apply ass appropriate to each menu item. For instance, if User1 can see item 1 but not item 2 you might have code like:

      bool canSeeItems = GetUserRights("this_user");
      item1.Visible = canSeeItems;
      item2.Visible != canSeeItems;

      Very simplistic but you can expand from this.

      "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups