ASP.NET Modal Popup 只显示灰色页面

ASP.NET Modal Popup only displays grayed out page

编辑:link to error pic

我是 ASP.NET 的新手,我无法使用模态弹出窗口,我认为这与在 _Layout 中包含正确的脚本有关,但经过大量搜索后我找不到方法获得的不仅仅是视图上的灰色覆盖层。

_Layout

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"/>
      @Styles.Render("~/Content/css")
      @Scripts.Render("~/bundles/modernizr")
      @Scripts.Render("~/bundles/jquery")
<script src="~/Scripts/jquery-ui-1.11.4.min.js"></script>
      @Scripts.Render("~/bundles/jqueryajax") ;
      @Scripts.Render("~/bundles/bootstrap")
</head>
<body>
<div class="container body-content">
 @RenderBody()
 @RenderSection("scripts", required: false)
</div>

索引

<div id="modal1" class='modal fade in'>
<div id="modal2">
</div>
</div>
 <input type="button" id="btn" value="Click to popup"/>
 <script type="text/javascript">
$(document).ready(function () {
    $("#btn").click(function () {
        $.ajax({
            cache: false,
            url: '@Url.Action("Modal")',
            success: function (data) {
                $("#modal2").html(data);
                $("#modal1").modal('show');
            }
        });
    });
});

模态弹出窗口的 HTML 看起来不像 right.Please 请查看下面 bootstrap 模态弹出窗口的外观以及使用 [=23= 显示它的示例]:

<head>
    <title></title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.3/jquery.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
    <script type="text/javascript">
        $(function () {
            $("#btn").click(function () {
                var data = "Some test data...";
                $(".modal-body").html(data);
                $("#modal1").modal('show');
            });
        });
    </script>
</head>
<body>
    <input type="button" id="btn" value="click" />
    <!--Modal start-->
    <div id="modal1" class="modal fade">
        <div class="modal-dialog">
            <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" id="myModalLabel">Modal popup</h4>
                </div>
                <div class="modal-body">
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>
    <!-- Modal end-->
</body>

输出:

(通过数据属性):

无需写入即可激活模式 JavaScript。在控制器元素(如按钮)上设置 data-toggle="modal" 以及 data-target="#foo"href="#foo" 以针对要切换的特定模式。

你可以试试这个

<!-- Button trigger modal -->

<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">show my modal </button>

        <!-- Modal -->
         <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
      <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>
            <h4 class="modal-title" id="myModalLabel">Modal title</h4>
        </div>
      <div class="modal-body">This is my content</div>
      <div class="modal-footer">
           <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
           <button type="button" class="btn btn-primary">Save changes</button>
       </div>
      </div>
   </div>
   </div>
  <!-- /.modal -->

通过JavaScript

使用单行 JavaScript:

调用 id 为 myModal 的模态
   $('#myModal').modal(options)