什么是语法的MVC 4强类型的ActionLink与MVC 4期货? [英] What is the syntax for a strongly-typed ActionLink in MVC 4 with MVC 4 Futures?
问题描述
我使用的是新的MVC 4互联网应用模板,我已经安装了的NuGet包MVC 4期货的Visual Studio 2012年。在我的 _Layout.cshtml
我建立导航菜单。
这工作,并建立正确的URL:
@ Html.ActionLink(客户,索引,客户)
这是什么,我想工作,一个强类型的变化:
@ Html.ActionLink< CustomersController>(C => c.Index(),客户,NULL)
据忧患无法选择方法组方法。您是不是要调用一个方法?,但东西告诉我,这不是真正的问题。
这编译并输出正确的HTML,而不是在线:
@ {
VAR T = Html.ActionLink< CustomersController>(C => c.Index(),客户);
回复于(T);
}
你如何建立强类型的动作/ ActionLink的在MVC 4使用Razor的语法(含或不含期货)?
@(Html.ActionLink< CustomersController>(X => x.Index(),客户))
<一个href="http://trycatchfail.com/blog/post/ASPNET-MVC-3-Razor-C-and-VBNET-WebForms-ActionLink-RenderPartial-and-RenderAction-in-WebForms.aspx"相对=nofollow>基础 - (强类型)链接到MVC操作
这<一href="http://stackoverflow.com/questions/9756139/difference-between-parenthesis-and-curly-brackets-in-razor">question松散覆盖它。
I am using a new MVC 4 Internet application template with Visual Studio 2012. I have installed the Nuget package for MVC 4 Futures. In my _Layout.cshtml
I am building the navigation menu.
This works and builds the correct URL:
@Html.ActionLink("Customers", "Index", "Customers")
This is what I would like to work, a strongly-typed variation:
@Html.ActionLink<CustomersController>(c => c.Index(), "Customers", null)
It griefs on "Cannot choose method from method group. Did you mean to invoke a method?", but something tells me that's not the real issue.
This compiles and outputs the right HTML, but not inline:
@{
var t = Html.ActionLink<CustomersController>(c => c.Index(), "Customers");
Response.Write(t);
}
How do you build strongly-typed Action/ActionLink's in MVC 4 using Razor's syntax (with or without Futures)?
@(Html.ActionLink<CustomersController>(x => x.Index(), "Customers"))
The Basics – (Strongly-Typed) Linking to MVC Actions
This question covers it loosely.
这篇关于什么是语法的MVC 4强类型的ActionLink与MVC 4期货?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!