I have marked a property as readonly in the model class, like this:
public class RegisterModel
{
[Display(Name = "User name")]
[ReadOnly(true)]
public string UserName { get; set; }
...
}
and in my view:
@Html.EditorFor(m => m.UserName)
but when I run the application, the textbox is not readonly.
I know I can use html attributes in the view to make it readonly, but I would prefer if this can be done in the model class itself.
Can it be achieved?