我在控制器中有这个方法
[HttpDelete]
public void DeleteDocument(int id)
{
//Here I do the deletion in the db
}
在视图中我有这个,调用一个返回部分视图的方法
@{ Html.RenderAction("GetDocumentsByMember"); }
GetDocumentsByMember 方法
public ActionResult GetDocumentsByMember()
{
var companyGuid = HttpContextHelper.GetUserCompanyGuid();
var documents = _service.GetUploadedDocumentsByMember(companyGuid);
return PartialView(documents);
}
和局部视图
@model IEnumerable<GradientCapital.DomainModel.Entity.Document.Document>
<div id="uploadeddocuments">
@*Here there's a table and at one of the columns there's the next link*@
<td id="delete">
@Ajax.ActionLink("Delete", "DeleteDocument", new { id = document.Id },
new AjaxOptions
{
Confirm = "Are you sure you want to delete?",
HttpMethod = "DELETE",
OnComplete = "deleteComplete"
})
</td>
</div>
而 deleteComplete 只是刷新所有内容
<script type="text/javascript">
function deleteComplete() {
window.location.reload();
}
</script>
对于一个简单的问题,代码很长(格式是否正确?),我不能让 ajaxoption UpdateTargetId 在这里工作,而不必调用这个 deleteComplete 函数。任何的想法?
谢谢