简体   繁体   English

html css菜单可见性按权限隐藏

[英]html css menu visibility hide by permissions

I would like use an html/css menu and hide menu items based on users permissions/rights. 我想使用html / css菜单并根据用户的权限/权限隐藏菜单项。 What would be the best way to handle this? 处理此问题的最佳方法是什么? Can it be done just using CSS/HTML or using scripting like Javascript. 可以仅使用CSS / HTML或使用Javascript之类的脚本来完成。

The permissions are through "allow roles" subfolders with web.config authorizations. 权限通过具有web.config授权的“允许角色”子文件夹进行。 So users cannot go to the wrong page but I want to hide the choices they can't actually access. 因此,用户无法转到错误的页面,但是我想隐藏他们实际上无法访问的选择。

I am using VB.net code behind FYI. 我在FYI后面使用VB.net代码。

You can't do this in static CSS/HTML, but you could print different CSS statements for each role if you dynamically generate it. 您不能在静态CSS / HTML中执行此操作,但是如果您动态生成它,则可以为每个角色打印不同的CSS语句。

Or you could assign class 'admin' to certain items, set to display:none in CSS then use jQuery to show them: 或者,您可以将“ admin”类分配给某些项目,在CSS中设置为display:none,然后使用jQuery显示它们:

if(userIsAdmin)
{
    $('.admin').show();
}

However, I prefer to do this server-side if possible and only print certain items for certain users because, as Yoda said, anyone can see the source if you do it client side. 但是,我更愿意在服务器端进行此操作,并且只为某些用户打印某些项目,因为正如Yoda所说,如果您在客户端进行操作,则任何人都可以看到源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM