[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 Responses to [C#] Open webform in new browser window from C# codebehind page

  1. Try this:

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

  2. Oh, nice! Thanks! :-)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>