【发布时间】:2017-04-03 04:09:37
【问题描述】:
我正在尝试在引导模型中加载局部视图。因为我在父页面中有一个现有表单,而在部分视图中有另一个表单。我不能决定将表格放在一个页面上,因为那样表格中就会有一个表格。
下面是我在父页面中的复选框,勾选后会显示模型对话框:
<input type="checkbox" name="inputNewBornKMC" value="inputNewBornKMC" id="inputNewBornKMCCheckbox"> New Born
下面是父页面中的模态对话框:
<div Class="modal fade" id="inputNewBornKMC" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close modal-close-btn" data-dismiss="modal">×</button>
<h4 class="modal-title">Search Newborn's Mother</h4>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
@*<button type="button" class="btn btn-default" id="AddGP">Save changes</button>*@
</div>
</div> <!-- Modal content-->
</div>
</div> <!-- Modal -->
在 javascript 中,我输入以下代码来加载模态对话框:
$('#inputNewBornKMCCheckbox').on('change', function (e) {
var _this = $(this);
// if checked
if (_this.is(':checked')) {
$('#inputNewBornKMC').modal({
keyboard: false,
remote: '/controller/AddPartialRegistration'
}).show();
$('#inputNewBornKMCCheckbox').on('click', '.modal-link', function (e) {
e.preventDefault();
$(this).attr('data-target', '#inputNewBornKMC');
$(this).attr('data-toggle', 'modal');
});
}
在控制器中调用一个动作来显示局部视图:
public ActionResult AddPartialRegistration()
{
return PartialView("_PartialRegistration");
}
在 _PartialRegistration 页面中:
<div class="modal-body">
<form class="form-horizontal" id="frmSearchMother" role="form" >
Mother's MRN
<input type="text" class="form-control input-sm" id="popupMotherMRN" name="popupMotherMRN" />
IC/ID No
<input type="text" class="form-control input-sm" id="popupICNo" name="popupICNo" />
Mother's Name
<input type="text" class="form-control input-sm" id="popupMotherName" name="popupMotherName" />
<button type="button" class="btn btn-default" id="SearchMother" >Search</button>
</form>
<br />
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="LoadMotherDetailsTable">
<thead>
<tr>
<th>No.</th>
<th>Mother's MRN</th>
<th>Mother's IC No</th>
<th>Mother's Name</th>
<th></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
我尝试了许多人们应用局部视图的方法,但都没有奏效。我不确定如何将部分视图插入到模态对话框的模态体中。选中复选框时可以显示此对话框,但我不确定如何在modal-body中加载部分视图。
任何帮助将不胜感激。
【问题讨论】:
标签: c# jquery bootstrap-modal asp.net-mvc-partialview