1

I'm writing an MVC application, and I have a view for editing users, which contains a series of possible user roles. Each user has exactly one role, so I'm using radio buttons for the "UserRole" property, each of which gives it a different value e.g.

<div class="form-inline">
    @Html.RadioButtonFor(model => model.UserRole, UserRoles.GlobalAdministrator)
    @Strings.GlobalAdmin
</div>
<div class="form-inline">
    @Html.RadioButtonFor(model => model.UserRole, UserRoles.VenueAdministrator)
    @Strings.VenueAdmin
</div>
<div class="form-inline">
    @Html.RadioButtonFor(model => model.UserRole, UserRoles.None)
    @Strings.BasicUser
</div>

Which works fine, but I'd rather use a Display Attribute to be more consistent with the rest of my code. Is there an easy way of setting the UserRoles Display attribute to do this? (e.g., in a different ViewModel I have)

[Display(ResourceType = typeof(Strings), Name = "VenuePermissions")]
public IEnumerable<int> SelectedVenuePermissions { get; set; }
tereško
  • 58,060
  • 25
  • 98
  • 150

0 Answers0