如何在新选项卡中打开剃刀操作链接? [英] How to have a a razor action link open in a new tab?

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

问题描述

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

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 没有设置 Target 的参数,因为它只返回一个 URL.

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天全站免登陆