Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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);
}


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
Posted

1 solution

Current User ->
C#
string strName = HttpContext.Current.User.Identity.Name.ToString();

for Current Role ->
C#
string[] selectedUsersRoles = Roles.GetRolesForUser(selectedUserName);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900