控件权限管理思路

1、编写判断用户角色相关的类及方法。

protected bool ShowButtonBasedOnRole(string RoleOfInterest)
{
      return User.IsInRole(RoleOfInterest);  
}

2、通过调用相关方法控制控件的显示与否、能不能使用。

<asp:Button ID="Button1" runat="server" Text="Button" Visible='<%# (bool) ShowDeleteRowBasedOnRole("administrator") %>'> />
如果存在多个角色,需要使用当前控件,可以将角色信息以参数的形式传入方法ShowDeleteRowBasedOnRole()中进行判断,确实是否允许使用当前控件。

转载于:https://www.cnblogs.com/lanchong/archive/2011/12/22/2297791.html

猜你喜欢

转载自blog.csdn.net/weixin_33939843/article/details/94705012
今日推荐