使用Ajax.ActionLink打开Bootstrap模式时,ASP MVC CheckBoxes和RadioButtons无法单击

时间:2016-02-17 20:27:27

标签: jquery asp.net ajax asp.net-mvc

我有一个ASP MVC应用程序,我正在尝试使用test.cshtml从我的Ajax.ActionLink视图中打开一个Bootstrap模式。它打开正常,但控件(复选框和单选按钮)不可点击。这只有在我使用Ajax.ActionLink时才会发生。

test.cshtml:

@{
    Layout = "";
}
@{
    ViewBag.Title = "test";
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - My ASP.NET Application</title>

    <link href="~/Content/bootstrap.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-2.2.0.js"></script>
    <script src="~/Scripts/bootstrap.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
    @*<script src="~/Scripts/jquery.validate.js"></script>
    <script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
    <script src="~/Scripts/modernizr-2.6.2.js"></script>
    <script src="~/Scripts/respond.js"></script>*@
</head>

    <script>
        function ShowPopup() {

            $("#divmodal").attr('data-toggle', 'modal');
            $('#divmodal').modal('show');
        }
    </script>
<body>
    <h2>test</h2>
    @Ajax.ActionLink("Open using Ajax Link!", "test", "Home", null, new AjaxOptions { UpdateTargetId = "divresponse", OnComplete = "ShowPopup" }, new { @class = "btn btn-info btn-sm" })

    <div class="modal fade" id="divmodal" tabindex="-1" role="dialog">
        <div class="modal-dialog">
            <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">Modal title</h4>
                </div>
                <div class="modal-body">
                    <label>Check Box</label>

                        <input type="checkbox" name="vehicle"   value="car"> 


                        <input type="checkbox" name="vehicle" value="Bike">  
                    <br />
                    <label>Radio Button</label>
                    <input type="radio" name="rdb"/>
                    <input type="radio" name="rdb"   />


                    </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><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</body>
</html>

和控制器代码== Homecontroller =很简单:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace TestQuestionsAnswers.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /test/

        public ActionResult test()
        {
            return PartialView();
        }
    }
}

0 个答案:

没有答案