0

how can I show button for specific user and hide it for another one based on security role in ASP.NET MVC 2.

For example if I have Create button in my view how to show it only for admin and hide it for any other user.

Thanks.

Kris van der Mast
  • 16,343
  • 8
  • 39
  • 61
Mazen
  • 1,487
  • 2
  • 13
  • 14

1 Answers1

1
<% if (User.IsInRole("admins"))
{ %>
    <input type="button" value="Create" />
<% } %>

Where "admins" is the name of your Role

Greg B
  • 14,597
  • 18
  • 87
  • 141