I have a list view with list of task. Each task have it state displays in DropDown list. Also I have a controller method to change task state. My view:
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.TaskText)
</td>
<td>
@Html.DisplayFor(modelItem => item.TillDate)
</td>
<td>
@Html.EnumDropDownListFor(modelItem => item.State, new { @class="state", @onchange="Drop()"})
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id = item.Id })
</td>
</tr>
}
My controller method:
[HttpPost]
public ActionResult UpdateState(int id, int state)
{
context.UpdateState(id, state);
return View();
}
Also I have such JQuery code:
function Drop()
{
$.ajax(
{
url: "UpdateState",
type: "POST",
success: function ()
{ alert("123123"); }
}
);
alert("asdasd");
}
How I can dynamicyle create url for ajax that will contain item id and selected state?