在Bootstrap Modal弹出窗口中加载局部视图存在问题。我可以将prodId作为参数传递给模态弹出窗口吗?
控制器操作:
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Details(string INFO)
{
return PartialView("DetailsPartialView");
}
型号:
<div class="modal" id="DetailsPopup" tabindex="-1" role="dialog" data-backdrop="static"
data-keyboard="true" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
@Html.Partial("../Controller/DetailsPartialView")
</div>
</div>
</div>
按钮:
<button type="button" class="btn btn-default" id="btnDetails">Details</button>
$("#btnDetails").click(function () {
$('#DetailsPopup').appendTo("body").modal('show');
});
答案 0 :(得分:0)
您可以将数据传递到Html.Partial中:
<div class="modal" id="DetailsPopup" tabindex="-1" role="dialog" data-backdrop="static" data-keyboard="true" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
@Html.Partial("../Controller/DetailsPartialView", new { id = yourId })
</div>
</div>
</div>
然后您就像在常规视图中一样在局部视图中使用它。如果您对此更熟悉,也可以传递模型类。