有没有办法将客户端验证与 SPARK 视图引擎一起使用?
我有以下 SPARK 视图:
<script type="text/javascript" src="~/content/script/shared/MicrosoftAjax.js?${ApplicationStartTime}"></script>
<script type="text/javascript" src="~/content/script/shared/jquery-ui-1.7.2.custom.min.js?${ApplicationStartTime}"></script>
<script type="text/javascript" src="~/content/script/shared/jquery.validate.min.js?${ApplicationStartTime}"></script>
<script type="text/javascript" src="~/content/script/shared/jquery.validate.unobtrusive.js?${ApplicationStartTime}"></script>
<script type="text/javascript" src="~/content/script/shared/MicrosoftMvcJQueryValidation.js?${ApplicationStartTime}"></script>
<viewdata model="Business.Models.Development.Dtos.DonationFormDto" />
#Html.EnableClientValidation();
<form id="form" action="~/development/donate.mvc" method="post">
<label>
*First Name
</label><br/>
<input type="text" name="model.FirstName" Id="FirstName" value="${Model.FirstName}"/> ${Html.ValidationMessage("model.FirstName")}
<br/>
</form>
服务器端验证工作正常,但客户端验证不行。
我可以通过使用 ASP.NET Helpers 和如下形式的语法使其工作:
using (Html.BeginForm("Index", "Donate", FormMethod.Post, new {id = "form", action="donate.mvc" }))
{
<%=Html.LabelFor( model => model.FirstName) %><br/>
<%=Html.TextBoxFor(model => model.FirstName)%>
<%=Html.ValidationMessageFor( model => model.FirstName) %><br/>
}
但是后来我的模型没有正确绑定,并且服务器端验证在提交时失败。
有什么建议么?放弃 SPARK 并创建经典的强类型视图是唯一的选择吗?