使用按钮并在ASP.NET中打开新的浏览器选项卡 [英] Using a button and open a new browser tab in ASP.NET
本文介绍了使用按钮并在ASP.NET中打开新的浏览器选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Using a button and open a new browser tab in ASP.NET??
Am using this code it's not working
if (Request.QueryString["newtab"].ToLower() == "true")
{
Response.Redirect("manifestHAWB_Print.aspx");
}
推荐答案
您无法从服务器代码打开新窗口。你必须在客户端做到这一点。如果您使用的是ASP按钮,则可以使用:
You can't open a new window from server code. You have to do it client-side. If you are using an ASP Button you can use:
OnClientClick="window.open('~/manifestHAWB_Print.aspx', target = '_blank');return false;"
如果您需要先访问服务器端,那么当您在那里时,只需注册一个启动脚本with window.open():
If you need to visit the server-side first, then when you're there, just register a startup script with window.open():
ScriptManager.RegisterStartupScript(this, this.GetType(), "launch", "window.open('~/manifestHAWB_Print.aspx', target = '_blank')", true);
按钮点击事件:
On button click event:
function ButtonClicked() {
var newWindow = window.open();
}
这将在浏览器中加载一个没有任何内容的新标签。您还可以打开一个包含所需内容的新窗口。
This will load a new tab in browser without any content. You also can open a new window with your required content.
您好b $ b
查看此链接http://www.aspsnippets.com/Articles/ASPNet-ResponseRedirect-or-ServerTransfer-Open -New-Tab-from-Code-Behind.aspx [ ^ ]
Hi
Check this link http://www.aspsnippets.com/Articles/ASPNet-ResponseRedirect-or-ServerTransfer-Open-New-Tab-from-Code-Behind.aspx[^]
这篇关于使用按钮并在ASP.NET中打开新的浏览器选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文