Guest User

Untitled

a guest
Jan 20th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. //////////////// VIEW ////////////////
  2. // model info and initialization logic
  3. @using (Html.BeginForm("EditTimesheet", "ControllerName", FormMethod.Post, new { enctype = "multipart/form-data", id = "editTimesheet" }))
  4. {
  5. @Html.ValidationSummary(true)
  6. <fieldset>
  7. <table width="100%">
  8. <tr>
  9. <td colspan="14" align="right">
  10. // lots of code
  11. </td>
  12. </tr>
  13. @Html.EditorFor(m => m.Rows)
  14. <tr>
  15. <td colspan="14" align="right">
  16. // lots of code
  17. </td>
  18. </tr>
  19. // closing statements
  20.  
  21. //////////////// EditorFor ////////////////
  22. // model info and initialization logic
  23. <tr class="timesheet-row">
  24. <td>
  25. <a href='#'>
  26. <img src='@Url.Content("~/Content/Images/delete.gif")'
  27. width='17' height='17' style='border: 0;'
  28. onclick="DeleteRow(this, @Model.RowId)" />
  29. </a>
  30. </td>
  31. // other td's
  32. </tr>
  33.  
  34. //////////////// JS file ////////////////
  35. function DeleteRow(box, rowId)
  36. {
  37. $(box).closest(".timesheet-row").remove();
  38.  
  39. // HACK: despicable, detestable HACK!
  40. var url = deleteRowUrl;
  41. url += '?rowId=' + rowId;
  42. var ajaxData = {
  43. type: "POST",
  44. url: url,
  45. dataType: "json",
  46. contentType: "application/json; charset=utf-8",
  47. data: null,
  48. success: null,
  49. error: function (error) {
  50. alert("There was an error posting the data to the server: " + error.responseText);
  51. }
  52. };
  53. $.ajax(ajaxData);
  54. }
  55.  
  56. <input type="text" name="Items[0].Id" value="1" />
  57. <input type="text" name="Items[1].Id" value="2" />
  58. <input type="text" name="Items[2].Id" value="3" />
  59. <input type="text" name="Items[3].Id" value="4" />
  60. <input type="text" name="Items[4].Id" value="5" />
  61.  
  62. <input type="text" name="Items[0].Id" value="1" />
  63. <input type="text" name="Items[1].Id" value="2" />
  64. <input type="text" name="Items[3].Id" value="4" />
  65. <input type="text" name="Items[4].Id" value="5" />
Add Comment
Please, Sign In to add comment