I'll write this as an answer, because it's too much text for a comment.
You want to show just a single item as a popup. To do so, you have multiple general approaches:
Render everything server side and hide what you don't need
In the end, each popup is just HTML. Typically a <div>
element. So one option is, to render all popups in your razor view and simply hide them all with CSS. Now you can add a css class to make one of them visible.
MyView.cshtml
@foreach(var reservation in Model.Reservations)
{
<div click="document.getElementById('@reservation.id').style.display='block';">
reservation list item
</div>
<div id="@reservation.id" style="display:none">reservation details</div>
}
You would encapsulate parts in js functions and reservation.id might not be the right property for an HTML id attribute, but I guess you've got the idea.
Render only list and fetch HTML fragments
Here you render the list only, then you use javascript to load an HTML fragment from the server.
MyController.cs
getReservationDetails(Guid reservationId) {
var reservation = load(reservationId);
// popup html only, no layout, no body tag, ...
return View(reservation);
}
In your list, you'll need a js function that passes the reservationId as URL parameter and shows thre response (the reservation details) in your popup. Pls see below for some common JS frameworks that provide modals.
Pass reservations as data to javascript and render client side
Here you pass all your reservations to javascript as data. Then you can create the popup in JavaScript
<script>
const reservations = [{ ... reservation as json }, { ... }];
function showReservation(index) {
// render and show in JS
}
</script>
See How to get JSON object from Razor Model object in javascript. Example lib to render HTML with javascript: https://github.com/janl/mustache.js/
Fetch details as data
Here you create
- An action that returns reservation details for single reservation. It accepts an URL parameter
reservationId
and returns the details as JSON.
- JavaScript function that accepts reservation id, loads data from server and renders the data as popup
See e.g. How to return a Json from a .Net Core Web API?
Links
Modals
Misc
This is just a starting point. You could think about which option is right for you, try it and then continue in a new SO post, if you have problems with the details.