title: ASP.NET MVC 3 Razor: How to get Action URL in a Javascript string variable?
body: <pre><code>@(Html.ActionLink("Link Label", 
      "ActionMethodName", 
      "ControllerName", 
      null, // parameter object, then html object
      null))
  </code></pre>
  
  <p>produces</p>
  
  <pre><code>&lt;a href="/ControllerName/ActionMethodName/"&gt;Link Label&lt;/a&gt;
  </code></pre>
  
  <p>If I want to reference the <code>/ControllerName/ActionMethodName/id</code> in a JavaScript template for the <code>Edit</code> or <code>New</code> link, how would I assign that to a JavaScript variable?</p>
  
  <p>attempt:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      var actionUrl = '@(Html.ActionLink("","ActionMethodName",
                                         "ControllerName",null,null))';
  &lt;/script&gt;
  </code></pre>
  
  <p>but at that point, I would have to use Javascript to remove the unwanted <code>&lt;a href...</code> characters in the string.</p>