我有一個控制器,我在其中回傳部分視圖中的資料,我想呼叫一個模式,怎么做?
我將我的控制器的詳細資訊留給您并在下面查看。
控制器
[HttpPost]
public async Task<ActionResult> Items(List<string> items)
{
var dto = new ItemsDetails();
dto.item = items;
return PartialView($"~/Views/Items/ItemDetails.cshtml", dto);
(Here I want to call a modal)
}
查看那是我要呼叫的模態。
<!-- Modal -->
@model Application.ItemsDetails
<div class="modal fade" id="items" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
uj5u.com熱心網友回復:
您使用 javascript 打開模式。
那應該是一個引導模式。
要輕松選擇您的模態,您應該給它一個id這樣的:
<div class="modal fade" id="myModal">
然后將此腳本放在檔案的底部
<script type="text/javascript">
$('#myModal').modal('show');
</script>
為此,必須先加載 JQuery 和 Bootstrap .css 和 .js 檔案。如果這些加載在頁面底部,您將需要延遲腳本呼叫,直到頁面完全加載。
更多資訊可以在這里找到: https ://getbootstrap.com/docs/4.0/components/modal
如果它不起作用,請檢查瀏覽器控制臺是否有錯誤 (F12)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/435133.html
標籤:javascript html 网 asp.net-mvc
下一篇:ASP.NETCore中的<aasp-page="linkhere">和<ahref="linkhere">有什么區別?
