ASPNET MVC - Why is ModelState.IsValid false “The x field is required” when that field does have a value?

后端 未结 3 1986
孤城傲影
孤城傲影 2021-01-12 06:45

I have a model like this:

public PurchaseOrder 
{
    [Required] [StringLength(15)]
    public virtual string OrderNumber {get;set;}
    // etc.        
}
         


        
3条回答
  •  轮回少年
    2021-01-12 07:10

    Are you sure that the error is coming from the OrderNumber field?

    It seems strange that the error message has Order Number in 2 words.

    Try changing the name of the field or removing the required tag to make sure that this is where the error is coming from.

提交回复
热议问题