Guest User

Untitled

a guest
Aug 28th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. @model IEnumerable<TrainingDotNetCoreMVC.Models.MovieModel>
  2. @{
  3. ViewData["Title"] = "Movie index";
  4. }
  5. <h1>@ViewData["Title"]</h1>
  6. @Html.ActionLink("+ เพิ่ม", "Delete", "Movie", null, new { @class = "btn btn-primary", @style = "margin-bottom: 20px;" })
  7. <br>
  8. <table class="table">
  9. <tr>
  10. <th>รหัสภาพยนต์</th>
  11. <th>ชื่อภาพยนต์</th>
  12. <th>รูป</th>
  13. <th>เข้าฉายเมื่อ</th>
  14. <th>หมวดหมู่</th>
  15. <th>ความยาว (นาที)</th>
  16. <th>ลบ</th>
  17. </tr>
  18. @foreach (var item in Model)
  19. {
  20. <tr>
  21. <td class="item-id">@item.id</td>
  22. <td>@item.title</td>
  23. <td>
  24. <img src="@item.coverImg" height="80px" />
  25. </td>
  26. <td>@item.releaseDate.Value.ToString("dd MMM yyyy")</td>
  27. <td>@item.genre</td>
  28. <td>@item.duration</td>
  29. <td>
  30. <input type="button" value="Delete" class="btn btn-danger" />
  31. </td>
  32. </tr>
  33. }
  34. </table>
  35. @using (Html.BeginForm("delete", "movie", FormMethod.Post, new { name = "frmMovie", id = "frmMovie" }))
  36. {
  37. <input type="hidden" name="id" />
  38. }
  39.  
  40. @section Scripts
  41. {
  42. <script>
  43. $(".btn-danger").click(function () {
  44. if(!confirm('Do you really want to delete this movie?')) {
  45. return false;
  46. }
  47. var id = $(this).closest("tr").find(".item-id").text();
  48. document.frmMovie.id.value = id;
  49. document.getElementById("frmMovie").submit();
  50. });
  51. </script>
  52. }
Add Comment
Please, Sign In to add comment