1

我尝试在 asp.net 中使用引导模式框,但我遇到了问题。这是我的模态框:

<div class="modal fade" id="delete_project_modal" tabindex="-1" role="dialog" aria-hidden="true">
    <asp:UpdatePanel ID="upDelete" runat="server">
        <ContentTemplate>
            <asp:Panel ID="pnlProjectDelete" runat="server" DefaultButton="btnCancelDelete">
                <div class="smallBox clearfix modal-dialog" title="<%=Resources.Titles.DeleteProject %>">
                    <span class="smallBox_head_right"></span>
                    <h2 class="smallBox_head_left">
                        <asp:Label ID="Label1" runat="server" Text="<%$ Resources:Titles,DeleteProject %>" />
                    </h2>
                    <div class="smallBox_Content">
                        <div class="smallBox_Content2 clearfix">
                            <div class="form-group margin-bottom1 clearfix">
                                <div class="col-sm-12">
                                    <asp:Label ID="Label2" runat="server" Text="<%$ Resources:Messages,AreYouSureDelete %>" CssClass="error errorMassage" />
                                </div>
                                <div class="col-sm-12">
                                    <asp:Button ID="btnCancelDelete" data-dismiss="modal" runat="server" Text="<%$ Resources:Buttons,Cancel %>" CssClass="btn btn-default btn-left cancel-delete" OnClick="btnCancelDelete_Click" />
                                    <asp:Button ID="btnDelete" runat="server" Text="<%$ Resources:Buttons,Confirm %>" CssClass="btn btn-default btn-left" OnClick="btnDelete_Click" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
</div>

当我按下回车键时,我希望当这个框打开我的 asp 面板默认按钮时工作,但它不起作用。我怎么解决这个问题?谢谢你

4

1 回答 1

1

这比我想象的要容易:只需添加这个脚本,我的问题就解决了!

$(document).ready(function () {

        $('#delete_project_modal').on('shown.bs.modal', function (e) {

            $(this).find('.cancel-delete').focus();
        })
    });
于 2014-03-09T07:35:24.523 回答