Я использую модель представления со строгим типом для моего представления, проверка работает для всех текстовых полей, но не работает для загрузки файла, ниже приведен код:
<div class="bg-content-inner">
<% Html.EnableClientValidation(); %>
<% using (Html.BeginForm("Create", "Track", FormMethod.Post, new { enctype = "multipart/form-data" }))
{ %>
<%: Html.ValidationSummary("Please Correct the errors and try again")%>
<table cellpadding="2" cellspacing="2" border="0">
<tr>
<td style="width:100px;">
<div class="editor-label">
<%: Html.LabelFor(model => model.Name) %>
</div>
</td>
<td colspan="2">
<div class="editor-field">
<%: Html.TextBoxFor(model => model.Name, new { style = "width:300px;" })%>
<%: Html.ValidationMessageFor(model => model.Name,"Circuit Name Required") %>
</div>
</td>
</tr>
<tr>
<td>
Main Image
</td>
<td>
<div class="editor-field">
<input type="file" name="files" id="file1" style="color:White" />
<%:Html.ValidationMessageFor(model => model.ImageLarge,"Required") %>
</div>
</td>
</tr>
<tr>
<td>
Detail Image
</td>
<td>
<div class="editor-field">
<input type="file" name="files" id="file2" style="color:White" />
<%:Html.ValidationMessageFor(model => model.ImageSmall,"Required") %>
</div>
</td>
</tr>
<tr></table>