Removing Required Attribute from Class but MVC3 still won't post the form without a value in the text box

前端 未结 2 947
借酒劲吻你
借酒劲吻你 2021-01-12 07:50

I have a class. At one point, I had set the properties of the class to [Required] using System.ComponentModel....

Okay, then I realized this was not needed. I ha

相关标签:
2条回答
  • 2021-01-12 08:11

    If you have value type properties. Client validation will always generate required validations. If you don't want required validation for value types make them nullable.

    0 讨论(0)
  • 2021-01-12 08:18

    You have two options:

    1. Set property as nullable,
    2. Turn off required attribute for value types (see this answer)
    0 讨论(0)
提交回复
热议问题