Nic*_*ckP 4 asp.net-mvc asp.net-mvc-3 asp.net-mvc-4
我正在从VB转移到C#,并且在尝试使用C#中的等效代码来解决以下razor代码(将动作链接显示为按钮)时遇到问题?
@Html.ActionLink("Send Message", "SendCustomerMessage", "SendMessage",
New With {.id = currentItem.CustomerId}, New With {.class = "btn"})
Run Code Online (Sandbox Code Playgroud)
我不熟悉VB,但是当你创建这样的匿名对象时它应该工作:
@Html.ActionLink("Send Message", "SendCustomerMessage", "SendMessage",
new {id = currentItem.CustomerId}, new { @class = "btn"})
Run Code Online (Sandbox Code Playgroud)
我们@
之前需要class
属性,因为它class
是C#中的一个保留字.您可能想要阅读有关匿名类型的更多信息.