title: Calling JavaScript function from code behind after Response.End()
body: <p>In my <code>.aspx</code> page, I have a <code>div</code> that I need to hide using JavaScript after an attachment is downloaded. I used the below code to get it done. But since <code>Response</code> is coming into the scenes, the <code>HideDiv()</code> does not get fired.</p>
  
  <p>I even tried making the div a server control and setting visibility to <code>false</code>. I also tried putting the <code>ClientScript</code> part after the <code>Response.End();</code> and inside the <code>finally</code> block.</p>
  
  <pre><code>    try{
  
      ClientScript.RegisterStartupScript(this.GetType(), "Hide", "HideDiv()", true);
      Response.ContentType = "application/vnd.ms-excel";
      Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename + "");
      Response.Write(tw.ToString());
      Response.End();
  }
  catch (System.Threading.ThreadAbortException)
          {
  
          }
          catch (Exception ex)
          {
              //log error
          }
          finally
          {
  
          }
  </code></pre>
  
  <p>Any idea to get the JavaScript to work?</p>