我尝试使用Ajax.beginform提交表单。我尝试了一切,但我得到这个资源找不到错误。
我有两个模型 - PatientEligibility和PatientDetails。两者分别包含10-12个属性。
我使用这两个模型在viewmodel上创建,我试图在一个局部视图中使用一些属性并提交该数据按钮单击
我的观点 -
@model Portal.Models.EligibilityViewModel
<script type="text/javascript">
$(document).ready(function () {
$('input[type="checkbox"]').on('change', function () {
$('input[name="' + this.name + '"]').not(this).prop('checked', false);
});
});
</script>
<div class="row margin-top-0">
<div class="col-xs-12 col-sm-12">
<h4><b>Patient Eligibility</b></h4>
</div>
</div>
@using (Ajax.BeginForm("SubmitPatientEligibility", "Ophthalmic", new AjaxOptions { OnSuccess = "OnSuccess", OnFailure = "OnFailure" }))
{
<div class="row margin-top-10">
<div class="col-xs-12 col-sm-12">
<div class="margin-top-10">
<div class="checkbox">
<label>
@Html.CheckBoxFor(model => model.PatientEligibility.IsAboveSixty, new { @Name = "cbAgeEligibility", htmlAttributes = new { id = "cbAbvSixty", @class = "form-control", Name = "group1[]" } })
The patient is 60 or over
</label>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-12">
<div class="margin-top-10">
<div class="checkbox">
<label>
@Html.CheckBoxFor(model => model.PatientEligibility.IsBelowSixteen, new { @Name = "cbAgeEligibility", htmlAttributes = new { id = "cbUnderSixteen", @class = "form-control", Name = "group1[]" } })
The patient is under 16
</label>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-12">
<div class="margin-top-10">
<div class="checkbox">
<label>
@Html.CheckBoxFor(model => model.PatientEligibility.IsBetweenForty, new { @Name = "cbAgeEligibility", htmlAttributes = new { id = "cbAbovenForty", @class = "form-control", Name = "group1[]" } })
The patient is 40 or over and is the parent/brother/sister/child of a person who has or has had gloucoma
</label>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-12">
<div class="margin-top-10">
<div class="checkbox">
<label>
@Html.CheckBoxFor(model => model.PatientEligibility.IsStudent, new { @Name = "cbAgeEligibility", htmlAttributes = new { id = "cbStudent", @class = "form-control", Name = "group1[]" } })
The patient is full time student aged 16, 17 or 18 at the establishment below.
</label>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-12">
<div class="margin-top-10">
<div class="checkbox">
<label>
@Html.CheckBoxFor(model => model.PatientEligibility.IsPrisoner, new { data_toggle = "collapse", data_target = "#dvseenNotseen", htmlAttributes = new { id = "cbPrisoner", @class = "form-control" } })
The patient is prisoner on leave from the prison detailed below
</label>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-12">
<div class="margin-top-10">
@Html.LabelFor(p => p.PatientBenefit.NINNumber)
@Html.EditorFor(model => model.PatientBenefit.NINNumber, new { htmlAttributes = new { @class = "form-control", autocomplete = "off" } })
</div>
</div>
<div class="col-xs-12 col-sm-12">
<div class="margin-top-10">
<label>DATE OF BIRTH</label>
@Html.TextBoxFor(model => model.PatientBenefit.DOB, new { @class = "form-control", autocomplete = "off", @id = "datetimepicker1" })
</div>
</div>
<div class="row margin-top-10">
<div class="col-xs-12 col-sm-3">
<button class="btn btn-default" name="btnBack">Previous</button>
</div>
<div class="col-xs-12 col-sm-9 text-right">
<button class="btn btn-default" name="btnBack">Save Draft</button>
<button class="btn btn-success fa fa-chevron-right icon-right" name="btnNext" type="submit">Next</button>
</div>
</div>
}
我的模型是这样的 -
public class EligibilityViewModel
{
public PatientEligibility PatientEligibility { get; set; }
public PatientBenefit PatientBenefit { get; set; }
}
我试图在提交下一个按钮 -
时调用此方法 public class OphthalmicController : Controller
{
[HttpPost]
public ActionResult SubmitPatientEligibility(EligibilityViewModel model)
{
return null;
}
}
我不知道为什么但是我得到这个500错误资源找不到这个方法。
我在这里缺少什么?