从aspx继承角色到webusercontrol [英] Inherit Role from aspx to webusercontrol

查看:67
本文介绍了从aspx继承角色到webusercontrol的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我创建了一个webusercontrol menu.ascx,并从default.aspx中调用了ascx文件

Hi,

I created a webusercontrol menu.ascx and from my default.aspx I call the ascx file

if (User.IsInRole("DTRTEC"))
{
   Control MyControl = (Control)LoadControl("ControlTemplate/Menu.ascx");
   PlaceHolder1.Controls.Add(MyControl);
}



来自Menu.ascx,我需要了解当前角色和当前用户,因为此控件正被其他用户和角色使用.

我被这个迷住了.

问候
Dabsukol



from Menu.ascx I need to know the current role and current user becuase this control is being used by different user and roles.

I am stuck to this one.

Regards
Dabsukol

推荐答案

当前用户->
string strName = HttpContext.Current.User.Identity.Name.ToString();


当前职位->


for Current Role ->

string[] selectedUsersRoles = Roles.GetRolesForUser(selectedUserName);


这篇关于从aspx继承角色到webusercontrol的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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