我正在实施用户角色。我有用 HTML 绘制的菜单列表,我从后面的代码中控制它们的可见性。我有 3 个数据库表,User w/ User_Number, User_Role_ID
, Roles w/ Role_ID, Role_Name
, User_Roles w/ User_Role_ID, User_Number, Role_ID
. Role_ID
是链接到角色名称的整数。每个用户都被分配到其中六个整数之一,他们的角色基于此。除了我的Administrator
角色 int 3 之外,所有工作都按预期工作。它将允许我显示或隐藏基于此角色的任何表格,除了lstAdminMenu
. 我已经测试了所有其他角色和菜单,我可以在任何角色中显示任何菜单,lstAdminMenu
除了Administrator role
. 菜单控制是:
<li runat="server" id="lstAdminMenu"><a class="menuitem">Administration</a>
<ul class="submenu">
<li><a href="../Administrative/CreateStudent.aspx">Create Student</a></li>
<li><a href="../Administrative/EnrollStudent.aspx">Manual Enrollments</a></li>
<li><a href="../Administrative/EnrollStudent.aspx">Edit Student</a></li>
<li><a href="../Administrative/CreateStaff.aspx">Create Staff Member</a></li>
<li><a href="../Administrative/CreateAVOS.aspx">Create Advisor</a></li>
<li><a href="../Administrative/AddResults.aspx">Input Grades</a></li>
<li><a href="../Administrative/FeesPaid.aspx">Fees</a></li>
<li><a href="../Administrative/NewModulesAndProg.aspx">Create Module</a></li>
<li><a href="../Administrative/AdminEditDegreesModules.aspx">Edit Modules</a></li>
<li><a href="../Administrative/EditStudentStatus.aspx">Student Status</a></li>
<li><a href="../Administrative/MarkModulesAsRunningSuspended.aspx"/>Module Status</li>
<li><a href="../Administrative/AddModuleEvents.aspx">Module Events</a></li>
<li><a href="../Administrative/PasswordGeneration.aspx">Password Reset</a></li>
<li><a href="../Administrative/Import.aspx">Import</a></li>
<li><a href="../Administrative/AddBuildingOrRoom.aspx">Create Estate</a></li>
</ul>
</li>
后面的代码:
'' Initialise Admin profile
Dim Administrator As Boolean
Administrator = False
For Each Role As Role In userPermissions
If Role.Role_ID = 3 Then
Administrator = True
Exit For
End If
Next
If Administrator Then
lstAdminMenu.Visible = True
lstAcademics.Visible = False
lstSeniorUM.Visible = False
lstAcademicPM.Visible = False
Else
lstAdminMenu.Visible = False
End If
此外,当我调试它时,它说角色是管理员并且可见性lstAdminMenu
是真实的。我根本无法弄清楚这一点。