Mazen
Mazen

Reputation: 1507

how to show hide&hide buttons for specific user in asp.net mvc2

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.

Upvotes: 0

Views: 881

Answers (1)

Greg B
Greg B

Reputation: 14888

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

Where "admins" is the name of your Role

Upvotes: 1

Related Questions