title: asp.net javascript message not showing up
body: <p>I have a button and onclick is set to this method which should display a simple JS alert pop up window:</p>
  
  <pre><code>string message = "File is already open. &lt;br&gt;Please close the file and try again.";
      System.Text.StringBuilder sb = new System.Text.StringBuilder();
      sb.Append("&lt;script type = 'text/javascript'&gt;");
      sb.Append("window.onload=function(){");
      sb.Append("alert('");
      sb.Append(message);
      sb.Append("')};");
      sb.Append("&lt;/script&gt;");
      ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
  </code></pre>
  
  <p>I have used the code above before and it has worked but not this time.
  The only difference is that I was using master pages for the other site and not for this one, and this one also has a timer going.</p>
  
  <p>Is there anything JS related to load in the <code>&lt;head&gt;</code> of the aspx page?</p>
  
  <pre><code>protected void btnToCSV_Click(object sender, EventArgs e)
      {
          try
          {
              StreamWriter writer = new StreamWriter(@"\\server location\test.csv");
  
              Some writer.write stuff...
  
              writer.Close();
          }
          catch (Exception ex)
          {
              lblMessage.Visible = true;
              string message = "File is already open. Please close the file and try again.";
              ClientScript.RegisterClientScriptBlock(
                 this.GetType(),
                "alert",
                string.Format("alert('{0}');", message),
                true);
  
          }
  }
  </code></pre>