I have got some code at the end of a button click event that uses RegisterStartupScript to open up a new Windows (its to a report for the user to print of)
After the page has loaded i would then like to re-direct the user away from the data entry page back onto the default page, but if i put a Response.Redirect in it does not open up my popup window. Any idea why the popup would not fire?
This is the c# code:
string myRptURL = "EstimateReport.aspx?id=" + hiddenID.Value;
string script = "window.open('" + myRptURL + "','')";
ClientScript.RegisterStartupScript(this.GetType(), "OpenWin", "<script>openNewWin('" + myRptURL + "')</script>");
Response.Redirect("default.aspx?mess=" + Server.UrlEncode("New Estimate Created"));
and this is the Javascript function:
<script language="javascript" type="text/javascript">
function openNewWin(url) {
var x = window.open(url, 'mynewwin', '_blank', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=520,modal=yes,alwaysRaised=yes');
x.focus();
}
The
Response.Redirectis canceling the script since it is not being sent to the client. redirect in javascript instead.