有沒有一種方法可以在SPARK視圖引擎中使用客戶端驗證?使用SPARK視圖引擎與ASP.NET MVC 2進行客戶端驗證
我有以下看法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助手和形式語法,像這樣的工作:
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並創建一個經典的強類型視圖是唯一的選擇?
m現在遇到了類似的問題,你找到了解決辦法嗎? – Yasser 2012-07-20 08:25:21