Bootstrap模式不会从后面的代码中显示出来

时间:2014-12-23 01:32:35

标签: asp.net vb.net twitter-bootstrap code-behind

应该很容易,但不起作用。我搜索并在互联网上找到了一个示例并使用Visual Studio 2013. div仅在表单中,每个都正确安装,表单中的引导程序工作正常。

Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

Page.ClientScript.RegisterStartupScript(Me.GetType(), "none", "$('#ModalZK');", True)


End Sub

div就像bootstrap示例一样,以

开头
<div class="modal fade" id="ModalZK" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only"></span></button>
        <h4 class="modal-title" id="myModalLabel4" style="text-align:center ">Title</h4>
      </div>
      <div class="modal-body">

1 个答案:

答案 0 :(得分:2)

$('#ModalZK');不会做任何事情。打开模态:

$('#ModalZK').modal('show');

有关详细信息,请参阅their documentation。如果对JavaScript正在做什么有疑问,请先在浏览器的控制台中运行它。如果您在Chrome中运行过您的行,您会看到一些HTML,表明它找到了该元素,但由于您没有调用任何函数,因此无法执行任何操作。

工作示例:

&#13;
&#13;
$('.ShowBtn').click(function() {
  $('#ModalZK').modal('show');
});
&#13;
<script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" />



<button type="button" class="ShowBtn">Show modal</button>

<div class="modal fade" id="ModalZK" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only"></span>
        </button>
        <h4 class="modal-title" id="myModalLabel4" style="text-align:center ">Title</h4>
      </div>
      <div class="modal-body">
&#13;
&#13;
&#13;