单击Asp Button控件显示Bootstrap Modal Pop-up

时间:2015-05-30 05:50:25

标签: asp.net bootstrap-modal

我试图在单击名为“午休时间”的按钮时显示弹出窗口,当使用正常的Bootstrap按钮控件时,它正常工作。

但是我想使用 asp:Button 控件来显示相同​​的弹出窗口,但单击该按钮时会出现弹出窗口,它只是刷新页面。

aspx代码:

 <asp:Button ID="btnLunchBreak" runat="server" Text="Lunch Break" CssClass="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal" />

    <div class="modal fade panel panel-primary" id="myModal" tabindex="-1" runat="server" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false" >
     <div class="modal-dialog panel panel-primary ">
       <div class="modal-content">
       <div class="modal-header">
       <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
         <h2 class="modal-title" id="gridSystemModalLabel" style="color: red">Lunch Break</h2>
       </div>
      <div class="modal-body">
      <div class="container-fluid">
       <br />
       <br />
       <asp:UpdatePanel ID="UpdatePanel3" runat="server">
      <ContentTemplate>
      <div class="row">
      <div class="col-md-4"></div>
      <div class="col-md-4">
      <asp:Button ID="btnLunchStart" runat="server" CssClass="btn btn-success" Text="Start" OnClick="btnLunchStart_Click" />
      <asp:Button ID="btnLunchStop" runat="server" CssClass="btn btn-success" Text="Stop" OnClick="btnLunchStop_Click" />
      </div>
       <div class="col-md-4"></div>
     </div>
    <div class="col-md-4"></div>
       <div class="col-md-4">
          <asp:Label ID="lbl_LTimer" runat="server" CssClass="h3" ForeColor="Blue"></asp:Label><br />
         <asp:Label ID="lbl_Lhour" runat="server" Visible="false" CssClass="h4" ForeColor="Black" Text="Hr :"></asp:Label>
        <asp:Label ID="lbl_LMin" runat="server" Visible="false" CssClass="h4" ForeColor="Black" Text="Min :"></asp:Label>
        <asp:Label ID="lbl_LSec" runat="server" Visible="false" CssClass="h4" ForeColor="Black" Text="sec"></asp:Label>
        <br />
   <asp:Label ID="lbl_LHr" runat="server" CssClass="h3" Font-Bold="true" Font-Size="20" ForeColor="red"></asp:Label>
         <br />
       <br /> <br /><br /><br /><br /><br />
     <asp:Label ID="lbl_Lbrkresp" runat="server" Visible="false"></asp:Label>
     <asp:Timer ID="Timer3" runat="server" Interval="1000000" OnTick="Timer3_Tick">
         </asp:Timer>
        </div>
       <div class="col-md-4"></div>
     </ContentTemplate>
        </asp:UpdatePanel>
   </div>
     </div>
     </div>
       <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>

我不熟悉bootstrap可能是以错误的方式做到了。建议任何解决方案

1 个答案:

答案 0 :(得分:1)

您可以尝试将属性UseSubmitBehavior设置为false。 因此,ASP不会呈现提交,而是呈现简单的按钮。

希望有所帮助! =)