我有一个根视图,其中包含两个部分视图,它们基于单击按钮加载到 div 中:
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Donation information</legend>
<p>
@Html.LabelFor(m => m.DonationType.DonationTypex) <br />
@Html.DropDownListFor(model => model.DonationType.DonationTypeID, ViewBag.DonationTypes as
SelectList, htmlAttributes: new { @id = "selectList" })
@Html.ActionLink("Select", "ContinueDonation", "Donation", htmlAttributes: new { @id =
"btnSelect1" })
</p>
<div id="donationSection1"></div>
<br />
<input id="btnAddPayment1" type="button" value="Add Payment Info" />
<br /><br />
<div id="paymentSection1"></div>
<input type="submit" id="btnSubmitDonation" value="Save" />
<input type="button" id="btnCancelDonation" value="Cancel" />
</fieldset>
}
加载到donationSection1和paymentSection1 div中的部分视图共享相同的模型,只包含其中不同属性的编辑器、标签等......只是想知道我怎样才能让它验证部分视图......如果提交/保存按钮位于根视图...
...加载 div 的 jquery ...(控制器返回共享相同模型的部分视图):
$("#btnSelect1").click(function () {
var donationTypeID = $(this).closest('p').find('#selectList').val();
var id = parseInt(donationTypeID);
var route = '/Donation/ContinueDonation?dTypeId=' + id;
$("#donationSection1").load(route, function () {
$("#donationSection1").show('slow');
});
return false;
});