Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @model IEnumerable<TrainingDotNetCoreMVC.Models.MovieModel>
- @{
- ViewData["Title"] = "Movie index";
- }
- <h1>@ViewData["Title"]</h1>
- @Html.ActionLink("+ เพิ่ม", "Delete", "Movie", null, new { @class = "btn btn-primary", @style = "margin-bottom: 20px;" })
- <br>
- <table class="table">
- <tr>
- <th>รหัสภาพยนต์</th>
- <th>ชื่อภาพยนต์</th>
- <th>รูป</th>
- <th>เข้าฉายเมื่อ</th>
- <th>หมวดหมู่</th>
- <th>ความยาว (นาที)</th>
- <th>ลบ</th>
- </tr>
- @foreach (var item in Model)
- {
- <tr>
- <td class="item-id">@item.id</td>
- <td>@item.title</td>
- <td>
- <img src="@item.coverImg" height="80px" />
- </td>
- <td>@item.releaseDate.Value.ToString("dd MMM yyyy")</td>
- <td>@item.genre</td>
- <td>@item.duration</td>
- <td>
- <input type="button" value="Delete" class="btn btn-danger" />
- </td>
- </tr>
- }
- </table>
- @using (Html.BeginForm("delete", "movie", FormMethod.Post, new { name = "frmMovie", id = "frmMovie" }))
- {
- <input type="hidden" name="id" />
- }
- @section Scripts
- {
- <script>
- $(".btn-danger").click(function () {
- if(!confirm('Do you really want to delete this movie?')) {
- return false;
- }
- var id = $(this).closest("tr").find(".item-id").text();
- document.frmMovie.id.value = id;
- document.getElementById("frmMovie").submit();
- });
- </script>
- }
Add Comment
Please, Sign In to add comment