Is there a way to open an asp:HyperLink.NavigateUrl in a new tab and not change location of the current?
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 });
}
}
<asp:HyperLink ID="HyperLink1"
runat="server"
NavigateUrl="http://yoursite.com"
Target="_blank">
This will work.
</asp:HyperLink>
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.
Worked for me:
[asp:HyperLink runat="server" ID="..." Target="_blank" Text=".......".../]
<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'));");