Question: 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 page in a new tab?

```
protected void btnSave_Click(object sender, EventArgs e)
{
    ...//some code to insert records
    Response.Redirect("NewQuote.aspx?val=" + this.txtQuotationNo.Text);//displaying gridview in other page to print what needed
}

```

Answer: 
if you are using http
then use below code

```
Response.Write("<script>window.open ('URL','_blank');</script>");

```

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!!
I spent quite some time on this, and while it does work to set the target on the form to \_blank it will mean that every other control on that page will attempt to open in a new window afterwards. And you can't manipulate the form back server side, since the response will never reach the orginal tab.

So I made it work with a combination of setting the target to \_blank when the button is clicked, and then shortly after reset the target back.

I put in this Javascript function on the page:

```
 <script type="text/javascript">
    function openInNewTab() {
        document.forms[0].target = "_blank";
        setTimeout(function () {
            document.forms[0].removeAttribute('target'); // After 500 ms revert back to normal mode so all other controls are not affected.
        }, 500);
    }

```

And on the control that needs to open in a new tab just add:

```
OnClientClick="openInNewTab();"

```