title: How do I display a confirmation message with trying to delete a record in ASP.NET Core using Razor Pages
body: <p>I'm using Razor Pages and seem to be struggling to display a confirmation message when a user clicks the delete button.</p>
  
  <p>On my Index.cshtml I have:</p>
  
  <pre><code>&lt;a asp-page-handler="Delete" asp-route-id="@item.Id" id="deleteBtn" class="btn bg-danger mr-1"&gt;&lt;i class="fas fa-trash-alt text-white"&gt;&lt;/i&gt;&lt;/a&gt;
  </code></pre>
  
  <p>These are generated as part of a foreach loop.</p>
  
  <p>My delete method:</p>
  
  <pre><code>public async Task&lt;IActionResult&gt; OnGetDelete(Guid id)
  {
      if (id == null)
      {
          return NotFound();
      }
  
      var record = await _context.LoadTable.FindAsync(id);
  
      if (record != null)
      {
          _context.LoadTable.Remove(record);
          await _context.SaveChangesAsync();
      }
  
      return RedirectToPage("./Index");
  }
  </code></pre>
  
  <p>I'm using Bootstrap so ideally would like to use it's modal to display the message. Displaying the message isn't the issue but rather I need to stop the method from firing until a user has confirmed that that's what they want to do, and with Razor Pages, I seem to be struggling.</p>
  
  <p>My thoughts were to have the delete button in the modal and the delete button shows the modal instead but I'm unsure how to pass @item.Id with it.</p>
  
  <p>Alternatively use JavaScript to intercept the button click?</p>