我的模型
[DataType(DataType.Text)]
[Display(Name = "Number of Employee")]
public int NumberOfEmployee { get; set; }
[DataType(DataType.Date)]
[Display(Name = "CEO Birthday")]
[DateRange(2)]
public DateTime CEO_Birthday { get; set; }
[DataType(DataType.Date)]
[Display(Name = "Organisation Anniversary")]
[DateRange(3)]
public DateTime OrgAnniversary { get; set; }
我查看
<tr>
<td style="border:0;">
<div class="editor-label">
@Html.LabelFor(m => m.NumberOfEmployee)
</div>
</td>
<td style="border:0;">
<div class="editor-field">
@Html.TextBoxFor(m => m.NumberOfEmployee)
</div>
</td>
</tr>
<tr>
<td style="border:0;vertical-align:middle;">
<div class="editor-label">
@Html.LabelFor(m => m.CEO_Birthday)
</div>
</td>
<td style="border:0;">
<div class="editor-field">
@Html.TextBoxFor(m => m.CEO_Birthday, new { @class="date"})
</div>
</td>
</tr>
<tr>
<td style="border:0;vertical-align:middle;">
<div class="editor-label">
@Html.LabelFor(m => m.OrgAnniversary)
</div>
</td>
<td style="border:0;">
<div class="editor-field">
@Html.TextBoxFor(m => m.OrgAnniversary, new { @class = "date" })
</div>
</td>
</tr>
我的Global.asax.cs
protected void Application_Start()
{
DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
.....
}
没有必要的财产在我的模型,但仍然我得到这个
我指该删除必填字段,但它为我的代码并不适用。 帮我删除必填字段。