Action Link Button

I am transitioning from VB to C # and am having trouble trying to work out an equivalent in C # for the next razor code (which shows the action link as a button)?

@Html.ActionLink("Send Message", "SendCustomerMessage", "SendMessage", New With {.id = currentItem.CustomerId}, New With {.class = "btn"}) 
+4
source share
2 answers

I am not familiar with VB, but it should work when you create anonymous objects as follows:

 @Html.ActionLink("Send Message", "SendCustomerMessage", "SendMessage", new {id = currentItem.CustomerId}, new { @class = "btn"}) 

We need @ before the class , because class is the word reserverd in C #. You can learn more about anonymous types .

+5
source

Override

enter image description here

Razor

 @Html.ActionLink("LinkText", "Action", "Controller", new { @id = currentItem.CustomerId }, new { @class = "abc" }) 
+2
source

Source: https://habr.com/ru/post/1500902/


All Articles