I have a partal view for my create a开发者_运维问答nd edit views.
In that partial is a: @Html.HiddenFor(model => model.ID)
In my POCO that property is not decorated with the [Required] attribute but when I go to the create page and click save the client side validation kicks in and says ID is required.
Why does it think that?
Integers are required by default unless you define it as int? (nullable int)
Value types are implicitly validated by the MVC framework.
To turn this off set DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes to false in global.asax
精彩评论