How to open page in new tab using the response. redirect at asp.net

后端 未结 8 2116
太阳男子
太阳男子 2021-01-03 23:42

I want to open a new tab or a new page by using Response.Redirect in a button click handler. I\'m using a query string to pass some values. How can I open he pa

8条回答
  •  花落未央
    2021-01-03 23:46

    if you are using http then use below code

    Response.Write("");
    

    this code cannot be used for https for https do below

    javascript in page

    function shwwindow(myurl) {
        window.open(myurl, '_blank');
    }
    

    in c# code behind

     string URL = ResolveClientUrl("~") + "**internal page path**";
        ScriptManager.RegisterStartupScript(this, this.GetType(), "show window", 
        "shwwindow('"+URL+"');", true);
    

    this code cannot bybass the browser popup blocker. user must allow it to run. for ie it opens in new window or new tab up to ie version in firefox and chrome it opens new tab

    enjoy it!!

提交回复
热议问题