MVC 3 Ajax.ActionLink 传递父模型属性
我有一个显示模型的视图,例如:
public class MyModel()
{
public string name {get;set;}
public IList<Note> notes {get;set;}
}
该视图显示模型的所有注释,我正在尝试使用 Ajax.ActionLink 删除注释,但为了删除注释,我需要传递控制器操作结果 ID模型的。
public ActionResult DeleteNote(int modelId, int noteId)
{
var franchise = _franchiseRepository.FindById(modelId);
Note note = new Note(noteId);
franchise.RemoveNote(note);
_franchiseRepository.SaveOrUpdate(franchise);
return View();
}
Ajax.ActionLink("Delete", "DeleteNote", new {id=item.id}, new AjaxOptions{HttpMethod="POST"})
这可以通过 ajax.actionlink 来完成吗?
提前致谢
I have a view which displays a model eg:
public class MyModel()
{
public string name {get;set;}
public IList<Note> notes {get;set;}
}
The view displays all the notes for the model, i am trying to use Ajax.ActionLink to delete a note, but in order to delete a note i need to pass my controller action result the ID of the model.
public ActionResult DeleteNote(int modelId, int noteId)
{
var franchise = _franchiseRepository.FindById(modelId);
Note note = new Note(noteId);
franchise.RemoveNote(note);
_franchiseRepository.SaveOrUpdate(franchise);
return View();
}
Ajax.ActionLink("Delete", "DeleteNote", new {id=item.id}, new AjaxOptions{HttpMethod="POST"})
Can this be accomplished with ajax.actionlink?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
DeleteNote
操作需要两个参数。我认为如果将ActionLink
更改为:Your
DeleteNote
action expects two parameters. I think it should work if you change theActionLink
to: