基于斯科特谷的博客,我一直在努力这样的:http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspxASP.Net MVC 2.0客户端验证回发
我的问题是,虽然我的脚本运行(在Firebug检查),我不明白任何错误。我的页面仍然在服务器上。我有启动Javascript太;)
我有以下看法代码:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Part1a.ViewModels.ProductModel>" %>
创建
<script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="../../Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>
<h2>Create Product</h2>
<% Html.EnableClientValidation(); %>
<% using (Html.BeginForm()) {%>
<fieldset>
<legend>Fields</legend>
<%= Html.LabelFor(model => model.Owner) %>
<%= Html.EditorFor(model => model.Owner) %>
<%= Html.ValidationMessageFor(model => model.Owner)%>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
<% } %>
<div>
<%: Html.ActionLink("Back to List", "Index") %>
</div>
,并使用了数据注释:
[DataType(DataType.Text)]
[DisplayName("Owner")]
[Required]
[StringLength(60)]
public string Owner { get; set; }
我也在使用Entity Framwork 4.0。
有没有人有任何想法为什么我的网页仍然回传?
非常感谢
特德
ASP.NET MVC 3.0? :) – 2010-07-01 12:10:00
2.0对不起 - 游戏提前:) – Ted 2010-07-01 13:19:22