Reputation: 1414
I am moving over from VB to C# and am having problems trying to work out an equivalent in C# for the following razor code (which shows an action link as a button)?
@Html.ActionLink("Send Message", "SendCustomerMessage", "SendMessage",
New With {.id = currentItem.CustomerId}, New With {.class = "btn"})
Upvotes: 4
Views: 19183
Reputation: 6728
@Html.ActionLink("LinkText", "Action", "Controller",
new { @id = currentItem.CustomerId }, new { @class = "abc" })
Upvotes: 2
Reputation: 38468
I'm not familiar with VB but it should work when you create anonymous objects like this:
@Html.ActionLink("Send Message", "SendCustomerMessage", "SendMessage",
new {id = currentItem.CustomerId}, new { @class = "btn"})
We need @
before class
property because class
is a reserverd word in C#. You may want to read more about anonymous types.
Upvotes: 6