I am trying to write a link to a partial view on the same page. Everything works, except that I am not able to pass in the needed month parameter through my ajax.actionlink syntax. I've tried using the ViewDataDictionary, but to no avail. Also, RouteValueParameter was a thought I had, but I'm trying to pass a string, not an integer id.
我试图在同一页面上写一个部分视图的链接。一切正常,除了我无法通过我的ajax.actionlink语法传递所需的月参数。我尝试过使用ViewDataDictionary,但无济于事。此外,RouteValueParameter是我的想法,但我试图传递一个字符串,而不是一个整数id。
Below is my code in the view, followed by the method in the controller:
下面是我在视图中的代码,后面是控制器中的方法:
<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);
}
Any ideas?
1 个解决方案
#1
13
Try this way
试试这种方式
@Ajax.ActionLink("Link Text", "MyAction", "MyController", new { month = "January", plum = "2", moreparams = "U can do this all day"}, new AjaxOptions{ UpdateTargetId = "view-month" } )
Greatings
#1
13
Try this way
试试这种方式
@Ajax.ActionLink("Link Text", "MyAction", "MyController", new { month = "January", plum = "2", moreparams = "U can do this all day"}, new AjaxOptions{ UpdateTargetId = "view-month" } )
Greatings