如何将表达式分配给模型属性,然后在 ActionLInk 的部分中使用它?
是否可以将 Lambda 表达式(操作?)分配给我的视图模型的属性,然后在 Partial 中使用该表达式?模型的属性类型应该是什么?伪代码:
视图模型
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())%>
我正在使用 Futures 程序集中的强类型 ActionLink。
Is it possible to assign an Lambda Expression (action?) to a property of my View Model, then use that expression in a Partial? What should the model's property type be? Psuedo Code:
View Model
public class MyModel
{
public ????? MyAction {get;set;}
}
Controller
public ActionResult Index()
{
var model = new MyModel();
model.MyAction = ?????<MyController>(x => x.DoThis());
return View(model);
}
public ActionResult DoThis()
{
return View();
}
Partial.ascx, How would I assign the action to the ActionLink?
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MyModel>" %>
<%=Html.ActionLink<Controller>(x => x.DoThis())%>
I am using the strongly typed ActionLink from the Futures assembly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
Try this: