【问题标题】:asp.net mvc4 ajax action linkasp.net mvc4 ajax 动作链接
【发布时间】:2013-09-12 13:04:03
【问题描述】:

祝大家有美好的一天,

我有一个包含 ajax 操作链接的 asp.net mvc4 项目。而且我有点困惑,当尝试发送 Id 值时,我会尝试下一个技巧:

@Ajax.ActionLink("Click", "StudentEdit" + "/" + Model.StudentId, new AjaxOptions
                                               {
                                                   HttpMethod = "POST",
                                                   LoadingElementId = "progress"
                                               })

接下来:

@Ajax.ActionLink("Click", "StudentEdit", new AjaxOptions
                                               {
                                                   HttpMethod = "POST",
                                                   LoadingElementId = "progress"
                                               }, new {id = Model.StudentId})

第一次只向ControllerName/StudentEdit发送请求

我的 VS2012 第二次出现错误:Cannot resolve method 'ActionLink' candidates next

接下来的问题是:如何将我的 Model.StudentId 属性发送到我的 ActionLink 编辑方法中?

P.S.:我有 GET StudentEdit() 和 POST StudentEdit(int id)

【问题讨论】:

  • 实际上您将 actionlink id 设置为 Model.StudentId,将其放在您的 ajaxoptions 之前,它可能会起作用
  • 谢谢你的回答,这对我有帮助

标签: asp.net ajax asp.net-mvc asp.net-mvc-4


【解决方案1】:
@Ajax.ActionLink("Click", "StudentEdit", new {id = Model.StudentId}, new AjaxOptions
                                           {
                                               HttpMethod = "POST",
                                               LoadingElementId = "progress"
                                           }

你的论点乱了套......它去:

  1. 链接文字
  2. 动作
  3. 路线价值
  4. Ajax 选项

这里是所有Ajax.ActionLink 重载。

【讨论】:

  • 非常感谢,这对我有帮助
猜你喜欢
  • 2013-07-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-03
  • 2022-10-02
  • 1970-01-01
相关资源
最近更新 更多