我有一个简单的登录模型类,几乎没有 DataAnnotation 验证
Public Class LoginUser
<Required()> _
Public Property UserName As String
<Required()> _
<StringLength(8)> _
Public Property Password As String
End Class
View是一个部分View,如下:
<% Using (Html.BeginForm("Login", "User", FormMethod.Post))%>
<% Html.EnableClientValidation()%>
<%= Html.ValidationSummary() %>
<table ID="loginTable" runat="server">
<tr>
<td>
<%= Html.LabelFor(Function(x) x.UserName)%>
</td>
</tr>
<tr>
<td>
<%= Html.TextBoxFor(Function(x) x.UserName)%>
<%= Html.ValidationMessageFor(Function(x) x.UserName) %>
</td>
</tr>
<tr>
<td>
<%= Html.LabelFor(Function(x) x.Password)%>
</td>
</tr>
<tr>
<td>
<%= Html.TextBoxFor(Function(x) x.Password)%>
<%= Html.ValidationMessageFor(Function(x) x.Password)%>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Login" />
</td>
</tr>
</table>
<% End Using%>
我相信我已经完成了显示验证消息所需的所有事情,但它没有,客户端验证也没有。我还在母版页的头部区域包含了以下脚本
<script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.min.js" type="text/javascript"></script>
<script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
<script src="../../Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>
是什么导致了这个问题?解决方案是什么?