是否可以将Lambda Expression(action?)分配给我的View Model的属性,然后在Partial中使用该表达式?模型的属性类型应该是什么? Psuedo代码:
查看模型
public class MyModel
{
public ????? MyAction {get;set;}
}
控制器
public ActionResult Index()
{
var model = new MyModel();
model.MyAction = ?????<MyController>(x => x.DoThis());
return View(model);
}
public ActionResult DoThis()
{
return View();
}
Partial.ascx ,我如何将操作分配给ActionLink?
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MyModel>" %>
<%=Html.ActionLink<Controller>(x => x.DoThis())%>
我正在使用期货装配中的强类型ActionLink。
答案 0 :(得分:0)
试试这个:
public class MyModel
{
Expression<Action<MyController>> Action { get; set; }
}
...
model.Action = x => x.DoThis();
...
<%= Html.ActionLink( Model.Action ) %>