0

I looked at the other questions concerning this topic, but could not get the solution to work, here is what I have from the other answer:

<asp:Panel ID="userOptionsPan" runat="server" Visible='<%# User.IsInRole("User") %>'>
    User options pan test
</asp:Panel>
<asp:Panel ID="employeeOptionsPan" runat="server" Visible='<%# User.IsInRole("Employee") %>'>
    Employee options pan test
</asp:Panel>

I log in with just the User role but both panel are still visible. How do I fix this?

I do not get any error messages, it just does not work.

Bill Software Engineer
  • 7,362
  • 23
  • 91
  • 174
  • Set visibility from codebehind, then you can also debug `User.IsInRole("Employee")`. Are you using a custom role-provider? What membership provider do you use(fe. `SqlMembershipProvider`)? Show us your web.config. – Tim Schmelter May 10 '12 at 13:09

1 Answers1

0

You are using a server call on a server property. This won't work , normally you use <%# %> tags to set html or javascript data, not server data.
You can either set the Style attribute (which is a html property) or you could set the visiblity on page_load like this :

userOptionsPan.Visible = user.IsInRole("User");
Kristof
  • 3,267
  • 1
  • 20
  • 30