部分查看代码:
public ActionResult ShowTaxPayer(int? page, string searchString)
{
var user = (from u in db2.Payers
select new Taxpayer
{
ID = u.objid,
Firstname = u.firstname,
Lastname = u.lastname,
Middlename = u.middlename,
Address = u.primaryaddress
});
if (string.IsNullOrEmpty(searchString))
{
return View(user.ToList().ToPagedList(page ?? 1, 10));
}
else
{
return View(user.Where(s => s.Firstname.Contains(searchString)).ToList().ToPagedList(page ?? 1, 10));
}
}
剃刀:
@using (Html.BeginForm("Index", "Wizard", FormMethod.Post))
{
@Html.ValidationSummary(true)
<fieldset>
<div class="wizard-step">
@Html.Label("Taxpayer Name")
@Html.TextBoxFor(m => m.taxpayername, new { data_toggle = "modal", data_target = "#myModal", data_backdrop = "static", data_keyboard = "false" })
@Html.ValidationMessageFor(m => m.taxpayername)
</div>
<div class="wizard-step">
@Html.Label("Taxpayer Address")
@Html.EditorFor(m => m.taxpayeraddress)
@Html.ValidationMessageFor(m => m.taxpayeraddress)
</div>
<div class="wizard-step">
@Html.Label("Trade Name")
@Html.EditorFor(m => m.tradename)
@Html.ValidationMessageFor(m => m.tradename)
</div>
<div class="wizard-step confirm">
</div>
<p>
<input type="button" id="back-step" name="back-step" value="<-- Back" />
<input type="button" id="next-step" name="next-step" value="Next -->" />
</p>
</fieldset>
}
模态:
<div class="modal fade" id="myModal" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
@{Html.RenderAction("ShowTaxPayer", "Wizard");}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
我只需要在模态中加载模型中的数据,而不是将我重定向到实际视图。提前致谢。
答案 0 :(得分:0)
这里是模型弹出
<div class="modal-body">
@{Html.RenderAction("ShowTaxPayer", "Wizard");}
</div>
并改为
<div class="modal-body" id="popupTableName">
</div>
并添加Javascript
<script>
window.onload = LoadTable();
function LoadTable(){
$.get( '@Url.Action("actionName","ControllerName", new { id = Model.ID } )', function(data) {
$('#popupTableName').html(data);
});
}
function onChange(){
LoadTable();
}
</script>