我正在尝试使用ASP.NET MVC 2.0测试版中的DataAnnotations验证程序进行安装,但使用以下模型:
public class Foo {
[Required] public string Bar {get;set;}
}
以及我的视图中的以下代码:
<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage<Foo>" %>
<!-- later on -->
<% Html.EnableClientValidation(); %>
<% using (Html.BeginForm("Edit","Foo")) { %>
从例子来看,一切都是一字不差的。排放的是:
<script type="text/javascript">
//<![CDATA[
EnableClientValidation({"Fields":[],"FormId":"form0"}, null);
//]]>
</script>
任何时候都不会发出任何消息来告诉任何javascript验证库(jquery或ms-ajax,无所谓)来验证字段。验证
做
在服务器端发生,但从不在客户机上发生,原因很明显。