我的 asp.net mvc-4 中有以下主视图:-
@model TMS.ViewModels.SwitchJoin
@Ajax.ActionLink("Add Port Info", "CreatePort","Switch",
new { switchid = Model.Switch.SwitchID },
new AjaxOptions {
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "AssignPort" ,
LoadingElementId = "progress"
}
)
</p>
//code goes here
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
以及以下两个局部视图;-
@model TMS.Models.TMSSwitchPort
@using (Ajax.BeginForm("CreatePort", "Switch", new AjaxOptions
{
InsertionMode = InsertionMode.InsertAfter,
UpdateTargetId = "Porttable",
LoadingElementId = "loadingimag",
HttpMethod= "POST",
OnSuccess="submitform"
}))
{
@Html.ValidationSummary(true)
@Html.HiddenFor(model=>model.SwitchID)
@Html.Partial("_CreateOrEditPort", Model)
<input type="submit" value="Save" class="btn btn-primary"/>
}
&&&
@model TMS.Models.TMSSwitchPort
@Html.AntiForgeryToken()
<div>
<span class="f">Device Tag</span>
@Html.TextBoxFor(model => model.Technology.Tag)
@Html.ValidationMessageFor(model => model.Technology.Tag)
<span class="f"> Port Number</span>
@Html.TextBoxFor(model => model.PortNumber)
@Html.ValidationMessageFor(model => model.PortNumber)
</div>
我有以下元类型模型类:-
public class TMSSwitchPort_Validation
{
[Required]
public string PortNumber { get; set; }
}
}
但是在 __CreateOrEditPort 部分视图上,所需的验证不会触发?有人可以建议吗?