插入更新删除并在同一视图中选择mvc 4

时间:2014-09-13 03:44:34

标签: asp.net-mvc-4 c#-4.0

我想在mvc 4 Razor的同一视图中插入更新删除和显示? 解决方案只是在同一视图中的许多局部视图? 您的所有建议都很有帮助

1 个答案:

答案 0 :(得分:0)

您可以在同一索引视图中执行所有基本插入,更新和删除操作

适用于创建

@Ajax.ActionLink(
"CreateText", 
"CreateMethod", 
"ControllerName",
new { id = item.EntityId}, 
new AjaxOptions { @UpdateTargetId = "CreateDivId" }) //create div in view and assign id to it so that edit form will appear there on click.

编辑

@Ajax.ActionLink(
"EditText", 
"EditMethod",
"ControllerName" 
new { id = item.EntityId}, 
new AjaxOptions { @UpdateTargetId = "EditDivId")  //create div in view and assign id to it so that edit form will appear there on click.

删除

@Ajax.ActionLink(
"DeleteText", 
"DeleteMethod",
"ControllerName" 
new { id = item.EntityId}, 
new AjaxOptions { @UpdateTargetId = "DeleteDivId" }) //create div in view and assign id to it so that edit form will appear there on click.