我试图弹出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 fade" id="notedetailModal" tabindex="-1" role="dialog" aria-labelledby="">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dissmiss="modal" aria-label="Close"><span aria-hidden="true">x</span></button>
<h4 class="modal-title" id="myModalLabel">Edit Note</h4>
</div>
<form method="post" role="form">
<div class="modal-body">
<div class="form-group">
<label>Title:</label>
<input type="text" name="Name" value="@Model.Name" />
</div>
<div class="form-group">
<label>Content:</label>
<textarea name="Content">@Model.Content</textarea>
</div>
</div>
<div class="modal-footer">
<input type="submit" class="btn btn-default" value="Update" />
</div>
</form>
</div>
</div>
</div>
答案 0 :(得分:1)
这是因为id="notedetailModal"
div不在“NoteListPartial.cshtml”页面上。
更改代码,例如将代码放在“NoteListPartial.cshtml”页面
中<div class="modal fade" id="notedetailModal" tabindex="-1" role="dialog" aria-labelledby="">
<div class="modal-dialog" role="document">
<div class="modal-content">
</div>
</div>
</div>
并在你的“Note.cshtml”中添加其余代码,如
<div class="modal-header">
<button type="button" class="close" data-dissmiss="modal" aria-label="Close"><span aria-hidden="true">x</span></button>
<h4 class="modal-title" id="myModalLabel">Edit Note</h4>
</div>
<form method="post" role="form">
<div class="modal-body">
<div class="form-group">
<label>Title:</label>
<input type="text" name="Name" value="@Model.Name" />
</div>
<div class="form-group">
<label>Content:</label>
<textarea name="Content">@Model.Content</textarea>
</div>
</div>
<div class="modal-footer">
<input type="submit" class="btn btn-default" value="Update" />
</div>
</form>
试试这个。