Bootstrap警报显示在asp.net的页面加载中

时间:2018-08-18 08:24:31

标签: c# asp.net twitter-bootstrap

我有点困惑,因为启动警报显示在asp.net的页面加载中,这是代码:-

<div class="col-lg-12">
    <div class="alert alert-danger alert-dismissable">
        <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
        <asp:Label ID="Label1" runat="server"></asp:Label>
    </div>
</div>

我想在执行某些任务时显示一些警报消息。

1 个答案:

答案 0 :(得分:0)

我添加了一个完全基本的示例来解释您的疑问。警报消息在加载时可见,因为您在任何情况下都不会隐藏消息。

在下面给出的代码段中,我使用jQuery-.show()在单击按钮时显示了警告消息。加载后,警报消息使用CSS-display: none隐藏。

$(document).ready(function(){
    $('.btn-danger').click(function(){
        $('.alert').show();
    }) 
});
.alert {
  display: none;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<div class="col-lg-12">
  <div class="alert alert-danger alert-dismissable">
    <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
    <label>Danger!</label>
  </div>
</div>
<div class="col-lg-12">
  <button type="button" class="btn btn-danger">Show Alert</button>
</div>

相关问题