使用Ajax.ActionLink将数据传递给控制器

Ski*_*erm 3 c# ajax asp.net-mvc-3

我正在尝试在同一页面上写一个部分视图的链接.一切正常,除了我无法通过我的ajax.actionlink语法传递所需的月参数.我尝试过使用ViewDataDictionary,但无济于事.此外,RouteValueParameter是我的想法,但我试图传递一个字符串,而不是一个整数id.

下面是我在视图中的代码,后面是控制器中的方法:

<td>@Ajax.ActionLink("January", "ControllerMethod", new ViewDataDictionary{{"month", "January"}}, new AjaxOptions { UpdateTargetId = "view-month" })</td>



public ActionResult ViewMonths(string month)
    {
        //some code here
        return PartialView("ViewMonths", schedule);
    }
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

And*_*wek 13

试试这种方式

@Ajax.ActionLink("Link Text", "MyAction", "MyController", new { month = "January",  plum = "2", moreparams = "U can do this all day"}, new AjaxOptions{ UpdateTargetId = "view-month" } )
Run Code Online (Sandbox Code Playgroud)

Greatings