【发布时间】:2011-05-17 16:30:48
【问题描述】:
A 有一个带有 Telerik MVC 网格的剃须刀视图。第一列有一个删除记录的链接。该链接是一个 Ajax Actionlink。
@(
Html.Telerik().Grid<QMS.Models.CustomerTableRow>(Model)
.Name("CustomerTable")
.Columns(c =>
{
c.Template(
@<text>
@Ajax.ActionLink("Delete","Delete", new { key = item.CustomerKey },new AjaxOptions{ Confirm="Delete this Customer?",UpdateTargetId = "CustomerTable", HttpMethod = "Delete"})
</text>
);
c.Bound(col => col.FirstName);
c.Bound(col => col.LastName);
c.Bound(col => col.Email);
c.Bound(col => col.HomePhone);
})
.Pageable()
.Sortable()
.Resizable(res => res.Columns(true))
.Scrollable()
)
//Action Method in view
//[HttpDelete] <-- can't have this or else a "Resource not found" error occurs
public ActionResult Delete(String key)
{
repo.DeleteCustomer(key);
return PartialView("CustomerTable", repo.GetCustomerTable());
}
当我点击我在模板列中创建的“删除”链接时,会发生一些奇怪的事情。首先,确认消息不会出现,但仍会调用删除操作。其次,即使我有 HttpMethod="Delete",如果我用 [HttpDelete] 装饰操作方法,我会收到“找不到资源”错误。最后,该网格处于局部视图中,并且操作方法在删除后返回局部视图,但是所有格式都丢失了,就好像 CSS 文件不再存在一样。如果链接在网格之外呈现,则不会发生这种情况。我使用的是 2011.1.315 版本
【问题讨论】:
标签: asp.net-mvc razor telerik