ReadOnly attribute doesn't work in ASP.NET MVC Models

后端 未结 4 1997
逝去的感伤
逝去的感伤 2020-12-18 20:41

I have marked a property as readonly in the model class, like this:

public class RegisterModel
{
    [Display(Name = \"User name\")]
    [Re         


        
4条回答
  •  一生所求
    2020-12-18 21:07

    ReadOnly attribute does not set the input to read-only.

    Try this

    Html.TextBoxFor(x => x.UserName, new { readonly = "readonly" })
    

提交回复
热议问题