I trying to get my link to open in a new tab (it must be in razor format):
<a href="@Url.Action("RunReport", "Performance", new { reportView = Model.ReportView.ToString() }, new { target = "_blank" })" type="submit" id="runReport" class="button Secondary">@Reports.RunReport</a>
This is not working though. Anyone know how to do this?
For
asp.net mvc ActionLink new tab with angular parameter
Looks like you are confusing Html.ActionLink() for Url.Action(). Url.Action has no parameters to set the Target, because it only returns a URL.
Based on your current code, the anchor should probably look like:
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 (liketarget="_blank"
, to open link in new tab) you can either:Add the target attribute to the
<a>
element by yourself:Use Html.ActionLink to generate an
<a>
markup element:Just use the
HtmlHelper
ActionLink
and set theRouteValues
andHtmlAttributes
accordingly.