My Model:
public class EntryModel
{
[Required]
public string Date { get; set; }
public string Car { get; set; }
public string Engine { get; set; }
public string User { get; set; }
public int CarCod { get; set; }
public int EngineCod { get; set; }
}
My View:
<%=Html.Label("Car")%>
<%=Html.Text("Car", car,new { @class = js_car")%>
<%=Html.ValidationMessageFor(x=>x.Car) %>
<%=Html.TextBox("CarCod", carCod, new { @class = "js_car", @style = "display:none;",@id="_car_cod" })%>
My Problem:
When posting the data, “CarCod” always fires an error at the ModelState, thus rendering both ModelState.IsValid and Html.ValidationSummary useless.
I already have workarounds for this (i.e not using them), but it would be very nice to know why.
To go off of what Garret said, make
CarCodandEngineCodnullable.