我在剃刀佩奇ASP.NET工作。我面臨的問題是,如果不使用引導模式,我無法使用鼠標或彈出窗口顯示用戶詳細信息
我做的如下
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#userDetailsModal">
View User Details
</button>
用于顯示用戶詳細信息的模式引導
<div class="modal fade" id="userDetailsModal" tabindex="-1" role="dialog" aria-labelledby="userDetailsModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="userDetailsModalLabel">User Details</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p><strong>User Name:</strong> @TempData["UserName"]</p>
<p><strong>User Role:</strong> @TempData["UserRole"]</p>
<p><strong>Environment:</strong> @TempData["Environment"]</p>
<p><strong>User ID:</strong> @TempData["UserId"]</p>
<p><strong>StatusCode:</strong> @TempData["StatusCode"]</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
我使用臨時數據將用戶詳細信息從模型傳遞到視圖,數據傳遞成功
想象一下我想做的事:
更新的帖子
你能為附加的樣本代碼應用popover嗎
從你的代碼來看,你是用Boostrap 4模態來顯示數據的,但現在Asp.Net核心是用Boostrap 5。Boostrap 4和Boostrap 5之間的代碼有些不同,您可以將您的代碼更新為:
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#userDetailsModal">
View User Details
</button>
<div class="modal fade" id="userDetailsModal" tabindex="-1" role="dialog" aria-labelledby="userDetailsModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="userDetailsModalLabel">User Details</h5>
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p><strong>User Name:</strong> @TempData["UserName"]</p>
<p><strong>User Role:</strong> @TempData["UserRole"]</p>
<p><strong>Environment:</strong> @TempData["Environment"]</p>
<p><strong>User ID:</strong> @TempData["UserId"]</p>
<p><strong>StatusCode:</strong> @TempData["StatusCode"]</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
上一篇c xml轉json代碼
下一篇自定義光標平滑過渡