如何拥有一个剃刀行动在新标签页中打开链接? [英] How to have a a razor action link open in a new tab?

查看:174
本文介绍了如何拥有一个剃刀行动在新标签页中打开链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让我的链接在新标签页中打开(它必须在剃刀格式):

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?

推荐答案

看起来你感到困惑的 Html.ActionLink()获得的 Url.Action()。 。Url.Action没有参数设定目标,因为它只返回一个网址

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:

<a href="@Url.Action("RunReport", "Performance", new { reportView = Model.ReportView.ToString() })" 
   type="submit" 
   id="runReport" 
   target="_blank"
   class="button Secondary">
     @Reports.RunReport
</a>

这篇关于如何拥有一个剃刀行动在新标签页中打开链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆