How do I set the visibility of a control based upon the current Role?

×

Use the HasRole function.  The HasRole function returns True if the current User has one or more of the comma separated list of Roles you hand it.  The control you are setting visible must have runat="server" set.

Set Visible if current User is in the Employee Role

<div id="Div4" runat="server" visible='<%# HasRole("Employee")  %>'>

Set Visible if current User is in the Supervisor or Manager Role

<div id="Div4" runat="server" visible='<%# HasRole("Supervisor,Manager")  %>'>