我有一个奇怪的问题,就是在通过Ajax.ActionLink呈现的局部视图中,非侵入式验证不起作用。
这是该局部视图:
@model MyWeb.Models.PersonSkill
@using (Ajax.BeginForm("EditSkill", null, new AjaxOptions { UpdateTargetId = "skills" }, new { id = "EditSkillForm" }))
{
@Html.HiddenFor(model => model.Id)
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.YearsOfExperience)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.YearsOfExperience)
@Html.ValidationMessageFor(model => model.YearsOfExperience)
</div>
<p>
<input type="submit" value="Save"/>
</p>
}
这个被称为:
@Ajax.ActionLink("Edit", "LoadEditSkill", new { id = item.Id }, new AjaxOptions() { UpdateTargetId = "editSkillDialog" }, new { @class = "editSkill" })
视图渲染正常。它向服务器提交数据,但是它只是没有验证。