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: 
I encountered this same problem today.

Response.write didn't work for me, to solve it I used instead System.Web.UI.ScriptManager.RegisterClientScriptBlock.

This is how your btnSave click event should be:

```
protected void btnSave_Click(object sender, EventArgs e)
{
    ...//some code to insert records
    System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "openModal", "window.open('NewQuote.aspx?val= "+ this.txtQuotationNo.Text+"' ,'_blank');", true);
}

```

NOTE: I'm using ScriptManager.RegisterClientScriptBlock because the button is inside an UpdatePanel, if that's not your case you should try:

```
protected void btnSave_Click(object sender, EventArgs e)
{
    ...//some code to insert records
    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "openModal", "window.open('NewQuote.aspx?val= " + this.txtQuotationNo.Text + "' ,'_blank');", true);
}

```
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();"

```