Javascript getting ignored because of Response.Redirect()
<p>I am currently working on asp.net using C# and I need to show a message box and confirm the input from user and redirect to another page, my code is something like this:     </p>

<pre><code>protected void Button1_Click(object sender, EventArgs e)
{
    System.Text.StringBuilder sb = new System.Text.StringBuilder();
    sb.Append("&lt;script language='javascript'&gt;");
    sb.Append("if (confirm('YES OR NO?')){ /*some javascript code*/ }");
    sb.Append("&lt;/script&gt;");

    Page.RegisterStartupScript("FocusScript", sb.ToString());
   Response.Redirect("Default.aspx");

}
</code></pre>

<p>here the problem is directly getting redirected to next page without showing message box. 
if i remove <code>Response.Redirect("Default.aspx");</code> it shows message box successfully. I think the here may be is <code>Response.Redirect()</code> has higher precedence compared to <code>javascript</code></p>

<p>I tried using </p>

<pre><code>sb.Append("if (confirm('YES OR NO?')){ window.location.href = \"Default.aspx"; }\");
</code></pre>

<p>instead of using <code>Response.Redirect()</code> but page didn't got redirected,  what should I do to resolve this problem?</p>
