Reputation: 78
I have a btn_click
event firing a method that should open the link but instead it opens 2 tabs: a duplicate of the open page and the desired link.
this is in the btn_click
.
Redirect_New_Tab("http://www.desiredlink.com");
and this is the method that it is calling.
private void Redirect_New_Tab(string url_To_Open)
{
string modified_URL = "window.open('" + url_To_Open + "', '_blank');";
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", modified_URL, true);
}
and the resault of this method is that there are now 3 tabs open. 2 duplicates of the original aspx page and a tab with the opened link.
is there anything I'm doing wrong or can do differently?
Upvotes: 0
Views: 97
Reputation: 398
Why not just call window.open
straight from OnClientClick
event?
<asp:Button ID="btn" runat="Server" OnClientClick="window.open('http://www.desiredlink.com')" />
Upvotes: 1