Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @foreach (var b in ViewBag.Workers)
- {
- <tr>
- <td><p>@b.Surname</p></td>
- <td><p>@b.Name</p></td>
- <td><p>@b.Patronymic</p></td>
- <td><p>@b.Position</p></td>
- <td>
- <form method="post" action="">
- <input type="hidden" value="@b.Id" name="WorkerId" />
- <input type="submit" value="Удалить" />
- </form>
- </td>
- </tr>
- }
- @foreach (var b in ViewBag.Workers)
- {
- <tr>
- <td><p>@b.Surname</p></td>
- <td><p>@b.Name</p></td>
- <td><p>@b.Patronymic</p></td>
- <td><p>@b.Position</p></td>
- <td>
- <button data-id="@b.Id">Удалить</button>
- </td>
- </tr>
- }
- ...
- <script>
- 'use strict';
- var urlToAction = '@Url.Action("RemoveItPlease", "Home")';
- $(document).ready(function() {
- $('table button').click(function (e){
- var workerId = $(e.target).data('id');
- $.ajax({
- url: urlToAction,
- method: 'POST',
- data: { id: workerId }
- });
- });
- });
- </script>
- ....
- public HomeController: Controller {
- [HttpPost]
- public ActionResult RemoveItPlease(int id) {
- ...
- }
- }
Add Comment
Please, Sign In to add comment