With Named arguments:
@Html.ActionLink(linkText: "TestTab", actionName: "TestAction", controllerName: "TestController", routeValues: null, htmlAttributes: new { target = "_blank"})
asp.net mvc ActionLink new tab with angular parameter
<a target="_blank" class="btn" data-ng-href="@Url.Action("RunReport", "Performance")?hotelCode={{hotel.code}}">Select Room</a>
That won't compile since UrlHelper.Action(string,string,object,object)
doesn't exist.
UrlHelper.Action
will only generate Urls based on the action you provide, not <a>
markup. If you want to add an HtmlAttribute (like target="_blank"
, to open link in new tab) you can either:
Add the target attribute to the <a>
element by yourself:
<a href="@Url.Action("RunReport", "Performance",
new { reportView = Model.ReportView.ToString() })",
target = "_blank" type="submit" id="runReport" class="button Secondary">
@Reports.RunReport
</a>
Use Html.ActionLink to generate an <a>
markup element:
@Html.ActionLink("Report View", "RunReport", null, new { target = "_blank" })
For
@Url.Action
<a href="@Url.Action("Action", "Controller")" target="_blank">Link Text</a>