在模型内单击按钮后关闭Bootstrap模态

时间:2016-07-15 03:23:41

标签: asp.net modal-dialog bootstrap-modal

在我的asp页面中,我有以下内容:

 <ContentTemplate> <div class="modal fade" id="myModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
     <asp:UpdatePanel ID="upModal" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
        <ContentTemplate>
            <div class="modal-content">
                 <div class="modal-header">
                     <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                     <h4 class="modal-title"><asp:Label ID="lblModalTitle" runat="server" Text=""></asp:Label></h4>
                 </div>
                 <div class="modal-body">
                     <asp:Label ID="lblModalBody" runat="server" Text=""></asp:Label>
                 </div>
                 <div class="modal-footer">
                   <asp:Button runat="server" ID="btnSavedata" CssClass="btn btn-info"> Text="Save"/>

                    <button class="btn btn-info" data-dismiss="modal" aria-hidden="true">Close</button>
                 </div>
             </div>
         </ContentTemplate>
   </asp:UpdatePanel>
 </div> </div>

我还有另一个链接,可以从后面的代码中显示Modal

Protected Sub btn_DeleteQuote_ServerClick(sender As Object, e As EventArgs) Handles btn_PrintQuote.ServerClick

lblModalTitle.Text = "Validation Errors List for HP7 Citation"
lblModalBody.Text = "This is modal body"
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal({backdrop:'static', keyboard: false});", True)
upModal.Update()

End Sub

现在我想要当我点击按钮btnSavedata(这个butoon里面的模态)我想更新我的页面内的一些内容(这个内容模态外)然后关闭模态 我想在btnSavedata_click事件

上使用代码

2 个答案:

答案 0 :(得分:1)

使用此代码:

ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal('hide');", True)

答案 1 :(得分:-2)

[http://www.w3schools.com/bootstrap/bootstrap_modal.asp][1]

Asp.net Modal

的完美示例

http://www.w3schools.com/bootstrap/bootstrap_modal.asp

<button type="button" class="btn btn-default" data-dismiss="modal">SAVE</button>