I have a controller where I return data in a partial view and I would like to call a modal, how can it be done?
I leave you the details of my controller and view below .
Controller
[HttpPost]
public async Task<ActionResult> Items(List<string> items)
{
var dto = new ItemsDetails();
dto = items;
return PartialView($"~/Views/Items/ItemDetails.cshtml", dto);
(Here I want to call a modal)
}
View
That is the modal that I want to call.
<!-- 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">
<tbody>
@foreach (var item in Model.Items)
{
<tr>
<td class="small">@item.Barcode</td>
<td class="small">@item.ErrorMsg</td>
<br>
</tr>
}
</tbody>
</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>