//Create user, create group
else if ((PermissionList.Any(item => item.Equals("Create group"))) && (PermissionList.Any(item => item.Equals("Create user"))) && (PermissionList.Any(item => item.Equals("Create message"))))
{
NavigationMenu.Items.Add(new MenuItem
{
Text = "Users",
NavigateUrl = "~/Users.aspx"
});
NavigationMenu.Items.Add(new MenuItem
{
Text = Groups",
NavigateUrl = "~/Groups.aspx"
});
}
<asp:Menu ID="NavigationMenu" runat="server" RenderingMode="Table" CssClass="menu"
EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
<Items>
</Items>
</asp:Menu>
</div>
I am adding items to the menu based on the user permission, here Since I have many combination of permission I have to do many condition and it is more than 20 combination. so for each combination I am executing code to add items to the menu, how can I add all menu items and remove the one for which the users doesnt have permission. Ex if the menu items are
“groups, users, message, support” then if the user permission is “create user”, then I should remove groups and messages from the menu, How can i do that.
I’m not sure on the specifics of how your logic works, but in the same way you’re using the
Addmethod for theItemscollection of your menu, you can use theRemoveorRemoveAtmethods to take menu items away.So, something like