How to open a new tab in asp.net

asp.net, c#, tabs

Solution

You cannot open a new page from code behind. Instead, you need to open at client side.

protected void Button1_Click(object sender, EventArgs e)
{
    string url = "http://www.stackoverflow.com";
    string script = string.Format("window.open('{0}');", url);

    Page.ClientScript.RegisterStartupScript(this.GetType(), 
        "newPage" + UniqueID, script, true);

    /* Use this if post back is via Ajax
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), 
        "newPage" + UniqueID, script, true); */
}

The problem of opening at client side is sometime pop-up blocker blocks the page.

Problem

I need to open an aspx page in a new tab, I searched differents solutions, but I've only found codes that open pop-ups and the browser blocks. I need to do it in the code behind I hope somebody help me, THANKS.

Original source

Related problems