Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Action link button

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"})
like image 752
NickP Avatar asked Feb 16 '23 08:02

NickP


1 Answers

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.

like image 71
Ufuk Hacıoğulları Avatar answered Mar 12 '23 05:03

Ufuk Hacıoğulları