Open a new page using HTML Response/JS ASP
<p>Alright, I have decided to go about this by opening a new page (newPage.aspx) which will then initiate the download and close after the download is completed. I am opening newPage.aspx using javascript by writing it to the response of the current page. For some reason, however, the window is not being opened before the original page is re-directed. Is their a method to be called before I redirect? Maybe I have a syntax issue?</p>

<pre><code>Response.Write("&lt;script type='text/javascript'&gt;window.open('~/newPage.aspx', '', ''); &lt;/script&gt;")

Response.Redirect("~/oldPage.aspx")
</code></pre>

<p><strong>EDIT:</strong></p>

<p>I tried the following but it did not work... (I am working in an Update Panel)</p>

<pre><code>ScriptManager.RegisterStartupScript(udpMain, udpMain.GetType(), "openExcel", "window.open('~/newPage.aspx', '' , '');", True)
</code></pre>

<p><strong>EDIT 2: So Close</strong></p>

<p>Ok, so this only works if I comment out the Response.Redirect. It seems that the RegisterStartupScript method takes place on the page load after the Response.Redirect method. Is there any known fix for this?</p>

<pre><code>ScriptManager.RegisterStartupScript(udpMain, udpMain.GetType(), "openExcel", "window.open(NewPage.aspx'); location.href='OldPage.aspx';", True)
Response.Redirect("~/OldPage.aspx")
</code></pre>
