0

i currently have:

        String url = "../CustomerSettings/CustomerConfiguration.aspx?CustomerID=" + sqlCommand.Parameters["@ReturnCustomerID"].Value.ToString();

        this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "myUniqueKey", "self.parent.location='"+url+"';", true);

this works great to redirect the parent page but I need it to open a new tab. Any suggestions?

w1ck3d64
  • 402
  • 2
  • 8
  • 15

1 Answers1

0

Something like this should work:

this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "myUniqueKey", "window.open(" + url + ",'_blank');", true);
QFDev
  • 8,668
  • 14
  • 58
  • 85
  • thanks for the quick reply..i tried that but no window opens anymore...keep in mind i want to open a tab in the PARENT window..i believe if that were to work, it would only open in the iframe – w1ck3d64 Mar 21 '13 at 18:03
  • 1
    window.open often gets caught up by pop-up blockers. If the window.open isn't initiated by a direct user input like clicking a button this will cause a problem for many users. – QFDev Mar 21 '13 at 18:08
  • 1
    Is this helpful? http://stackoverflow.com/questions/1037839/how-to-force-link-from-iframe-to-be-opened-in-the-parent-window Which suggests applying to the parent page to force all links inside the iframe to open within the parent. – QFDev Mar 21 '13 at 18:10
  • i used this and it works: this.Page.ClientScript.RegisterStartupScript(this.GetType(), "CustomerConfiguration", "window.focus();window.location='" + url + "';", true); thanks for the replies, they gave me some insight on what to do – w1ck3d64 Mar 21 '13 at 18:38
  • No problem.. Glad you sorted this! – QFDev Mar 21 '13 at 20:50