【发布时间】:2011-07-13 16:09:03
【问题描述】:
我的视图使用强类型视图模型,验证适用于所有文本字段,但不适用于文件上传,以下是代码:
<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>
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-2 validation