对话框内的MVC RenderAction

时间:2014-09-17 19:27:33

标签: asp.net-mvc partial-views renderaction

我希望有人可以帮助我。我在对话框中有一个RenderAction,这样我就可以使用更新的数据动态填充一些下拉列表。目前,在尝试重新渲染操作时保存后,对话框不会关闭。

这是包含对话框的部分视图:

<div id="beneficiary-add" tabindex="-1" role="dialog" aria-labelledby="modal-responsive-label" aria-hidden="true" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header modal-header-primary">
                <button type="button" data-dismiss="modal" aria-hidden="true" class="close">&times;</button>
                <h4 id="modal-responsive-label" class="modal-title">Add Beneficiary</h4>
            </div>
            @using (Html.BeginForm("AddBeneficiary", "Clients", FormMethod.Post, new { id = "form-add-beneficiary" }))
            {
                @Html.HiddenFor(x => x.ClientId)
                Html.RenderAction("AddBeneficiaryPartial", "Clients", new { id = Model.ClientId });
                <div class="modal-footer">
                    <button type="button" data-dismiss="modal" class="btn btn-default">Close</button>
                    <button type="submit" class="btn btn-primary">Save changes</button>
                </div>
            }
        </div>
    </div>
</div>

包含控制器返回的对话框的部分:

<div class="table-responsive">
<table id="table-beneficiaries" style="border-bottom:1px solid #ddd" class="table table-striped table-bordered table-hover">
    <thead>
    <tr>
        <th>Last Name</th>
        <th>First Name</th>
        <th>Address</th>
        <th>City</th>
        <th>State</th>
        <th>ZIP Code</th>
        <th>Relationship</th>
        <th>Edit</th>
        <th>Delete</th>
    </tr>
    </thead>
    <tbody>
        @foreach (var item in Model.ClientBeneficiaries)
        {
    <tr>
        <td>@item.ClientBeneficiary.LastName</td>
        <td>@item.ClientBeneficiary.FirstName</td>
        <td>@item.ClientBeneficiary.Address</td>
        <td>@item.ClientBeneficiary.City</td>
        <td>@item.ClientBeneficiary.State</td>
        <td>@item.ClientBeneficiary.ZipCode</td>
        <td>@item.Relationship</td>
        <td><a class="edit-beneficiary" data-id="@item.ClientBeneficiary.Id" style="cursor: pointer;">Edit</a></td>
        <td><a class="delete-beneficiary" data-id="@item.ClientBeneficiary.Id" style="cursor: pointer;">Delete</a></td>
    </tr>
        }
    </tbody>
</table>
<button type="button" data-target="#beneficiary-add" data-toggle="modal" class="btn btn-primary">Add Beneficiary</button>
@Html.Partial("_BeneficiaryAdd", new EG.Core.ViewModels.BeneficiaryViewModel() { ClientId = Model.Client.Id })
<div id="beneficiary-edit-container"></div>

不确定我在这里失踪了什么。

1 个答案:

答案 0 :(得分:0)

看起来你并没有在“AddBeneficiaryPartial”结尾处关闭你的div。图