ASP.NET MVC - Bootstrap-Modal弹出窗口,单击按钮

时间:2017-09-25 11:46:43

标签: asp.net-mvc popup bootstrap-modal

我试图弹出bootstrap。在我的" NoteListPartial.cshtml"页;如果我点击编辑按钮,我想要" Not.cshtml"弹出来打开。但是当我点击按钮时,没有任何反应。我的代码如下:

这是我的" NoteListPartial.cshtml":

<a href="@Url.Action("Note", "Project", new { ID = item.ID,ProjectID=item.ProjectID })" data-toggle="modal" data-target="#notedetailModal">Edit</a>

这是我的#34; Note.cshtml&#34;:

<div class="modal" id="notedetailModal" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title"><b>Edit Note</b></h4>
            </div>
            <div class="modal-body">
                <form method="post" class="form-horizontal" role="form">
                    <div class="form-group">
                        <div class="note note-info">
                            <h4 class="block"><b>Note Content:</b></h4>
                            <textarea name="Content" style="width: 230px">@Model.Content</textarea>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <input type="submit" class="btn btn-lg blue" value="Add Note" />
            </div>
        </div>
    </div>
</div>

2 个答案:

答案 0 :(得分:0)

您能否请添加以下代码角色=&#34;对话框&#34;像

<div class="modal" id="notedetailModal" tabindex="-1" role="dialog">

答案 1 :(得分:0)

从锚标记中删除网址并将div角色更改为对话框

<a href="" data-toggle="modal" data-target="#notedetailModal">Edit</a>

 <div class="modal" id="notedetailModal" tabindex="-1" role="dialog">

模型会弹出,但是对于编辑窗口,你需要在点击时添加ajax类型的内容请求,你需要像下面这样做:Render Partial View As Modal Popup Using AJAX Call with JSON