如何在Asp.net Mvc中使用其他URL在浏览器中打开一个新选项卡

时间:2016-04-05 04:53:02

标签: asp.net asp.net-mvc

我需要在浏览器的新标签页中打开当前网页的网址。我们如何从控制器操作中打开一个新选项卡。

public ActionResult AddDocumentControls(int DocInfo)
        {
     url="www.test.com";   
if(DocInfo==1)
{
open the url in a new tab
}
}

我试过

Page.ClientScript.RegisterStartupScript(
            this.GetType(), "OpenWindow", "window.open('url','_newtab');", true);

但是Page.ClientScript没有到达。

任何人都可以给我一些帮助。谢谢。

1 个答案:

答案 0 :(得分:1)

试试这个,

  @Html.ActionLink("linkText", "Action", new {controller="Controller"}, new {target="_blank"})



  <a href="@Url.Action("Action", "Controller")" target="_blank">Link Text</a>

Javascript方法,

window.open("Link URL")