如何在新选项卡中打开asp:HyperLink.NavigationUrl

时间:2022-02-03 07:24:58

Is there a way to open an asp:HyperLink.NavigateUrl in a new tab and not change location of the current?

有没有办法在新选项卡中打开asp:HyperLink.NavigateUrl而不更改当前位置?

5 个解决方案

#1


53  

use <asp:HyperLink Target="_blank" /> actually depending on the users settings that may open a new window.

实际上取决于可能打开新窗口的用户设置,使用

This works for a new tab in FF and Chrome, doesn't seem to work in IE (8), but this may depend on the doctype.

这适用于FF和Chrome中的新选项卡,似乎在IE(8)中不起作用,但这可能取决于doctype。

#2


7  

<asp:HyperLink ID="HyperLink1" 
     runat="server" 
     NavigateUrl="http://yoursite.com" 
     Target="_blank">
       This will work.
</asp:HyperLink>

#3


1  

<asp:HyperLink ID="lnkCompUrl" runat="server"  Width="200px"></asp:HyperLink></li>


lnkCompUrl.Text = Convert.ToString(dsData.Tables[0].Rows[0]["comp_url"]);
string url="http://"+Convert.ToString(dsData.Tables[0].Rows[0]["comp_url"]);

lnkCompUrl.NavigateUrl = String.Format("javascript:void(window.open('"+url+"','_blank'));");

#4


0  

protected void grdvEmployeeDetails_RowDataBound(object sender, GridViewRowEventArgs e)

{

    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        var firstCell = e.Row.Cells[0];            
        firstCell.Controls.Clear();           
        firstCell.Controls.Add(new HyperLink { NavigateUrl = String.Format("javascript:void(window.open('" + "EmployeeDetails.aspx?EmpId=" + firstCell.Text + "','_blank'));"), Text = firstCell.Text });

    }
}

#5


0  

Worked for me:

为我工作:

[asp:HyperLink runat="server" ID="..." Target="_blank" Text=".......".../]

#1


53  

use <asp:HyperLink Target="_blank" /> actually depending on the users settings that may open a new window.

实际上取决于可能打开新窗口的用户设置,使用

This works for a new tab in FF and Chrome, doesn't seem to work in IE (8), but this may depend on the doctype.

这适用于FF和Chrome中的新选项卡,似乎在IE(8)中不起作用,但这可能取决于doctype。

#2


7  

<asp:HyperLink ID="HyperLink1" 
     runat="server" 
     NavigateUrl="http://yoursite.com" 
     Target="_blank">
       This will work.
</asp:HyperLink>

#3


1  

<asp:HyperLink ID="lnkCompUrl" runat="server"  Width="200px"></asp:HyperLink></li>


lnkCompUrl.Text = Convert.ToString(dsData.Tables[0].Rows[0]["comp_url"]);
string url="http://"+Convert.ToString(dsData.Tables[0].Rows[0]["comp_url"]);

lnkCompUrl.NavigateUrl = String.Format("javascript:void(window.open('"+url+"','_blank'));");

#4


0  

protected void grdvEmployeeDetails_RowDataBound(object sender, GridViewRowEventArgs e)

{

    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        var firstCell = e.Row.Cells[0];            
        firstCell.Controls.Clear();           
        firstCell.Controls.Add(new HyperLink { NavigateUrl = String.Format("javascript:void(window.open('" + "EmployeeDetails.aspx?EmpId=" + firstCell.Text + "','_blank'));"), Text = firstCell.Text });

    }
}

#5


0  

Worked for me:

为我工作:

[asp:HyperLink runat="server" ID="..." Target="_blank" Text=".......".../]