我如何在ASP.NET中执行此操作?
main.Items[0].Enabled = false;
main.Items[1].Enabled = false;
folder.Items[0].Enabled = false;
folder.Items[1].Enabled = false;
答案 0 :(得分:0)
如果要在角色基础上启用/禁用菜单项,则可以在项目中使用站点地图,并根据用户角色轻松显示隐藏菜单。
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="" roles="*">
<!--<siteMapNode url="Default.aspx" title="Home" description="" roles="*" />-->
<siteMapNode url="Dash.aspx" title="Dash" description="admin" roles="KAM,Admin,QMR" />
<siteMapNode url="~Manage.aspx" title="Complaint List" description="" roles="Public,Admin" />
<siteMapNode url="~/Manage1.aspx" title="title1" description="" roles="role1,Admin" />
<siteMapNode url="~/Manage2.aspx" title="title2" description="" roles="role2,Admin" />
<siteMapNode url="~/ManageUsers.aspx" title="Administration" description="admin" roles="Admin" />
<siteMapNode url="" title="Reports" description="admin" roles="Admin" >
<siteMapNode url="Manage4.aspx" title="Manage123" description="admin" roles="Admin" />
<siteMapNode url="Summary.aspx" title="Summary" description="admin" roles="Admin" />
</siteMapNode>
</siteMapNode>
</siteMap>