如何将Model对象添加到我的AJAX.ActionLink中

时间:2012-10-05 19:31:15

标签: ajax asp.net-mvc-3

我有一个Html.ActionLink,我需要发布到服务器:

@Html.ActionLink("Some Text", "controller", "service", Model, new { @class = "btn btn-primary", @id = "someText" })

我尝试将其转换为AJAX帖子:

@Ajax.ActionLink("Some Text", "controller", "service", Model, new { @class = "btn btn-primary", @id = "someText" }, new AjaxOptions(){HttpMethod = "POST"})

字符串,字符串,字符串,对象,对象没有重载,如上面的Html.Actionlink。

我对AJAX不是很熟悉,但有没有办法告诉AJAX传递相同的数据?

1 个答案:

答案 0 :(得分:1)

看起来您的参数排序不正确。 AjaxOptions位于属性之前。

@Ajax.ActionLink("Some Text", "controller", "service", Model, new AjaxOptions(){HttpMethod = "POST"}, new { @class = "btn btn-primary", @id = "someText" })