[C#] Open webform in new browser window from C# codebehind page


Found a great little snip of code online today from csharphelp.com about how to open a new browser window from a C# codebehind:

Response.Write("<SCRIPT language=javascript>var w=window.open('Rpt_OrderStatus_Form.aspx','OrderStatus','height=800,width=800');</SCRIPT>");

…but, one of the comments on that thread is that the Response.Write disrupts the page appearance. Any thoughts/suggestions on a better way to open a new browser window from a C# codebehind?

2 Comments

  1. John says:

    Try this:

    ClientScript.RegisterStartupScript( this.GetType(), “PopupWindow”, “var w=window.open(‘Rpt_OrderStatus_Form.aspx’,’OrderStatus’,’height=800,width=800′);” );

  2. willwm says:

    Oh, nice! Thanks! 🙂

Leave a Comment

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s