我在cshtml文件中有一个dropdownlist:
var kategorie_wlasna = new SelectList( (from z in Model.Kategoria where !formReadOnly || z.Id == Model.KategoriaWlasnaId select z),"Id","Nazwa"); ... @Html.DropDownListFor( model => model.KategoriaWlasnaId,kategorie_wlasna,"----",htmlClassDropDownListDef)
在我的视图模型我有属性没有任何注释为必需:
public long KategoriaWlasnaId { get; set; }
但是该字段仍然是必需的。在浏览器中我得到:
<select class="input-validation-error form_object1" data-val="true" data-val-number="The field KategoriaWlasnaId must be a number." data-val-required="The KategoriaWlasnaId field is required." id="KategoriaWlasnaId" name="KategoriaWlasnaId"> <option value="">-----</option> <option value="1227">Wykroczenie</option> <option value="1228">Przestępstwo</option> </select>
我失踪了什么