[英]Window.open script manager is opening 2 pages
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.我有一个btn_click
事件触发一个应该打开链接的方法,但它打开了 2 个选项卡:打开页面的副本和所需的链接。 this is in the btn_click
.这是在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.这种方法的结果是现在打开了 3 个选项卡。 2 duplicates of the original aspx page and a tab with the opened link.原始 aspx 页面的 2 个副本和一个带有打开链接的选项卡。
is there anything I'm doing wrong or can do differently?有什么我做错了或可以做不同的事情吗?
Why not just call window.open
straight from OnClientClick
event?为什么不直接从OnClientClick
事件中调用window.open
呢?
<asp:Button ID="btn" runat="Server" OnClientClick="window.open('http://www.desiredlink.com')" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.