如何使用查询字符串重定向新选项卡 [英] How do I Redirect a new Tab with Query String

查看:59
本文介绍了如何使用查询字符串重定向新选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用查询字符串打开带有ID的新选项卡窗口。我尝试了所有可能的方法,即Onclientclick和其他方法。但不是。帮助我。提前谢谢



  if (e.CommandName == < span class =code-string> 项目
{
int ID = Convert.ToInt32(e.CommandArgument.ToString());
Response.Redirect( Add_Items.aspx?TestID = + ID);
}


受保护 void Page_Load(< span class =code-keyword> object sender,EventArgs e)
{
if (!IsPostBack)
{
int id = Convert.ToInt32(Request.QueryString [ TestID]);
lblTestID.Text = id.ToString();
}

解决方案

在浏览器的新标签页中打开页面是你无法控制的......这取决于浏览器和最终用户首选项...

实际上Response.Redirect甚至不支持目标信息...

您可以使用Response.Write创建客户端JavaScript代码打开具有特定目标的链接,如下所示:

 Response.Write( <脚本> window.open( 'Add_Items.aspx TestID = 1234?', '_空白');和LT; /脚本>中); 



当然这个代码也不能确保只在新窗口中打开新标签...


我们这个:



  string  url =  < span class =code-string> Add_Items.aspx?TestID = + ID; 
string fullURL = window.open( ' + url + ','_ blank');;
ScriptManager.RegisterStartupScript( this typeof string ), OPEN_WINDOW,fullURL,);


推荐此链接



http://stackoverflow.com/questions/8994285/how-do-i-use-target -blank-on-a-response-redirect [ ^ ]



http://forums.asp.net/t/1283761.aspx?Response+Redirect+URL+and+target+_blank+ [ ^ ]



http://www.aspsnippets.com/Articles/ASP.Net-Response.Redirect-or-Server.Transfer-Open-new-window.aspx [ ^ ]

How to open new tab window with passing ID using Query String. I tried all the possible ways, i.e Onclientclick and others. but not.help me. thank you in advance

if (e.CommandName == "Items")
        {
            int ID = Convert.ToInt32(e.CommandArgument.ToString());
            Response.Redirect("Add_Items.aspx?TestID=" + ID);
        }


protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int id = Convert.ToInt32(Request.QueryString["TestID"]);
            lblTestID.Text = id.ToString();
        }

解决方案

Opening pages in new tab of the browser is something you can not control...It depends on the browser and the end user preferences...
Actually Response.Redirect not even support target information...
You may use Response.Write to create a client side JavaScript code to open the link with a specific target, something like this:

Response.Write("<script>window.open('Add_Items.aspx?TestID=1234','_blank');</script>");


Of course this code too, can't ensure opening in new tab only in new window...


Us this:

string url = "Add_Items.aspx?TestID="  + ID;
 string fullURL = "window.open('" + url + "', '_blank' );";
               ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true);


refer this link

http://stackoverflow.com/questions/8994285/how-do-i-use-target-blank-on-a-response-redirect[^]

http://forums.asp.net/t/1283761.aspx?Response+Redirect+URL+and+target+_blank+[^]

http://www.aspsnippets.com/Articles/ASP.Net-Response.Redirect-or-Server.Transfer-Open-new-window.aspx[^]


这篇关于如何使用查询字符串重定向新选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆