i've been breaking my head over this one for a while now. i have the form below, which works fine.
@using (Html.BeginForm("Edit", "PCLLine", FormMethod.Post))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.ID)
@Html.HiddenFor(model => model.Field)
<div class="small">
@Html.TextBoxFor(model => model.Number, new { onchange = "setEditWBSElementNumber(this," + Model.ID + ")" })
@Html.ValidationMessageFor(model => model.Number)
</div>
<div class="large">
@Html.EditorFor(model => model.Description)
@Html.ValidationMessageFor(model => model.Description)
</div>
<div>
@Html.EditorFor(model => model.NumberTwo)
@Html.ValidationMessageFor(model => model.NumberTwo)
</div>
<div>
@Html.TextBoxFor(model => model.ConcatNumber, new { @id = Model.ID.ToString() + "_WBSElementNumber" })
@Html.ValidationMessageFor(model => model.ConcatNumber)
</div>
<div class="large">
@Html.EditorFor(model => model.Remarks)
@Html.ValidationMessageFor(model => model.Remarks)
</div>
<div>
<input type="submit" class="accept" value="Opslaan" />
</div>
<div>
<input class="folderButton" value="Opties" onclick="pclSubLineDialog()" />
</div>
<div>
<input class="delete" value="Verwijderen" onclick="deleteItem(); return false;" />
</div>
}
The problem here is in the delete. It calls the function, but does not execute properly. It does not hit my Controller actions, yet trying it with other controller actions, it does work:
function deleteItem() {
$.ajax({
url: "PCLLine/Delete",
type: "POST",
data: { id: "@Model.ID" },
dataType: "json",
success: function (data) {
alert('');
}
});
}
And the controller:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Delete(int pclLineId)
{
try
{
// TODO: Add delete logic here
_pclLineBLL.DeletePCLLine(pclLineId);
return Json(new { success = true });
}
catch
{
return Json(new { success = false });
}
}