Wednesday, August 24, 2011

a much better way to make links in Razor

@Html.ActionLink("Don't touch me", "Details", "Object", new { foo = "bar", baz = "qux" }, new { style = "text-decoration: line-through !important;" })

 
 

This is a much better way to do Razor links than this way. Jitendra Patil pointed it out to me today. The five parameters are:

  1. the name that will appear to a user for the link
  2. the Action
  3. the Controller
  4. URL line variables
  5. HTML in-line parameters for the link

No comments:

Post a Comment