如何根据ASP.NET webforms中用户的角色动态创建导航栏 [英] How to dynamically create navigation bar based on the role of user in ASP.NET webforms

查看:59
本文介绍了如何根据ASP.NET webforms中用户的角色动态创建导航栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用google搜索了一段时间,但仍然无法获得正确的文章或示例来帮我完成。我正在学习(学习)基于角色的应用程序,我做得很好。我目前遇到了问题。我在我的sql db中有一个名为SiteMap的表。此表包含以下列(id,Title,Description,Url,roles,parentId,TabType和TabOrder)。我有每列的值。我想要实现的是,当用户登录时,我想根据该用户的角色拥有导航栏。如果用户是访客,我想显示一个具有guest虚拟机角色的导航栏。我怎么样?



我尝试过的事情:



这里是数据库的样子



I have googled search for a while but still couldn't get the right articles or examples to put me through. I'm currently working(learning) on a role based application which i doing well. I'm currently having a problem. i have a table in my sql db called SiteMap. This table has the following columns (id, Title, Description, Url, roles, parentId, TabType and TabOrder). I have values for each columns. What i want to achieve is that when a user logs in, i want to have navbar based on the role of that user. If the user is a guest, I want to display a navbar with the roles of just guest. How do i have this?

What I have tried:

here is how the db looks like

id  Title          Description    Url        roles    parentId    TabType    TabOrder
  
 1   ROOT             ROOT                      *        NULL         0           0
 
 2   Administrator   Padmin     PortalAdmin#   Admin       1          1           2

 3   Report                      Reporting#    Admin       1          1           3
 
 4  Ticket                       Ticket     Admin;Guest    1          1           4

 5  Manage Ticket             Mticket.aspx    Guest        4          4           2





这里是摘要我想做的事。当具有guest用户角色的用户登录时,只有Ticket(具有子菜单Manage Ticket)应该在导航栏中。如果具有Admin角色的用户,则应在导航栏中显示Portal Administration,Report,Ticket(带子菜单Manage Ticket)。我希望你明白我解释的内容。谢谢



here is a summary of what i want to do. When a user that is with the role of guest logs in, only Ticket(with sub menu Manage Ticket) should be in the navbar. If its a user with Admin role, Portal Administration, Report, Ticket(with submenu Manage Ticket) should be displayed in the navbar. I hope you do understand what i explained. Thanks

推荐答案

你需要一个起点,看看这篇关于CP的文章 - 基于运行时用户权限的菜单控件绑定站点地图 [ ^ ]
As you need a starting point have a look at this article here on CP - Binding Sitemaps with Menu Control Based on User Privilege at Runtime[^]


这篇关于如何根据ASP.NET webforms中用户的角色动态创建导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆