How to disable or enable the html li of UI menu or child menu based on user level condition in ASP.net.
-
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
-
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
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 addID="unique_name_for_control"
andrunat="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