如何在Bootstrap模态弹出窗口中加载局部视图并将参数传递给actionresult以在模态窗口加载时加载网格?

tktrz96b  于 2022-12-07  发布在  Bootstrap
关注(0)|答案(1)|浏览(173)

在引导模式弹出窗口中加载部分视图时出现问题。我可以将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');
});
6yjfywim

6yjfywim1#

您可以将数据传递到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>

然后你可以像在常规视图中一样在局部视图中使用它。如果你更习惯的话,你也可以传递一个模型类。

相关问题