Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////// VIEW ////////////////
- // model info and initialization logic
- @using (Html.BeginForm("EditTimesheet", "ControllerName", FormMethod.Post, new { enctype = "multipart/form-data", id = "editTimesheet" }))
- {
- @Html.ValidationSummary(true)
- <fieldset>
- <table width="100%">
- <tr>
- <td colspan="14" align="right">
- // lots of code
- </td>
- </tr>
- @Html.EditorFor(m => m.Rows)
- <tr>
- <td colspan="14" align="right">
- // lots of code
- </td>
- </tr>
- // closing statements
- //////////////// EditorFor ////////////////
- // model info and initialization logic
- <tr class="timesheet-row">
- <td>
- <a href='#'>
- <img src='@Url.Content("~/Content/Images/delete.gif")'
- width='17' height='17' style='border: 0;'
- onclick="DeleteRow(this, @Model.RowId)" />
- </a>
- </td>
- // other td's
- </tr>
- //////////////// JS file ////////////////
- function DeleteRow(box, rowId)
- {
- $(box).closest(".timesheet-row").remove();
- // HACK: despicable, detestable HACK!
- var url = deleteRowUrl;
- url += '?rowId=' + rowId;
- var ajaxData = {
- type: "POST",
- url: url,
- dataType: "json",
- contentType: "application/json; charset=utf-8",
- data: null,
- success: null,
- error: function (error) {
- alert("There was an error posting the data to the server: " + error.responseText);
- }
- };
- $.ajax(ajaxData);
- }
- <input type="text" name="Items[0].Id" value="1" />
- <input type="text" name="Items[1].Id" value="2" />
- <input type="text" name="Items[2].Id" value="3" />
- <input type="text" name="Items[3].Id" value="4" />
- <input type="text" name="Items[4].Id" value="5" />
- <input type="text" name="Items[0].Id" value="1" />
- <input type="text" name="Items[1].Id" value="2" />
- <input type="text" name="Items[3].Id" value="4" />
- <input type="text" name="Items[4].Id" value="5" />
Add Comment
Please, Sign In to add comment