HttpPost在MVC 4中不适用于Modal Popup

时间:2013-04-19 12:59:36

标签: asp.net-mvc-4 http-post modal-dialog actioncontroller

我认为具有CompanyTable局部视图。所以这个局部视图有一个CreateBankAccount局部视图。最后的部分视图代码是

@model Invoice.Model.BankAccount

<script src="~/Scripts/jquery-1.7.1.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>



<a href="#@Model.TaxID" role="button" class="btn" data-toggle="modal">Launch demo modal</a>
<div id="@Model.TaxID" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">Modal header</h3>
    </div>
    <div class="modal-body">
        @using (Ajax.BeginForm("CreateModal", "CompanyController", new AjaxOptions { UpdateTargetId = "modal", HttpMethod = "post" }))
        {
            @Html.ValidationSummary(true)

            <fieldset>
                <legend>BankAccount</legend>

                @Html.HiddenFor(model => model.ID)

                <div class="editor-label">
                    @Html.LabelFor(model => model.BankName)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.BankName)
                    @Html.ValidationMessageFor(model => model.BankName)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.CorrespondentAccount)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.CorrespondentAccount)
                    @Html.ValidationMessageFor(model => model.CorrespondentAccount)
                </div>                   
                <input type="submit" value="save" />
            </fieldset>
        }
    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
        <input type="submit" class="btn btn-primary" value=" Save changes" data-dismiss="modal" />
    </div>
</div>

所以这个局部视图是模态弹出窗口。我的问题是,当我想创建bankAccount时,我的HttpPost方法不起作用,我返回Index动作。我怎么解决它?

0 个答案:

没有答案