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

后端 未结 4 2001
逝去的感伤
逝去的感伤 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条回答
  •  萌比男神i
    2020-12-18 20:53

    If you're using a SETTER you have to use { get; private set; }. That will make it so the client can't change the value. You can also just use an HTML 5 input and mark it there.

提交回复
热议问题