title: (Presumed) RegisterStartupScript and Response.Output.Write conflict
body: <p>I have two generic methods, one launches a javascript alert and the other downloads a StringBuilder into a text file.
  Usually, each one of them works perfect, but when I try to use both at the same time, only one works. I think is some kind of conflict between them, but I'm not sure.</p>
  
  <p>Can anyone give me a clue about what's happening?</p>
  
  <p>Here is the code from where i call both methods (ASP page Codebehind):</p>
  
  <pre><code>{
      Tools.MessageToUser(this, "Some random string");
      Tools.SaveStringToTextFile(stringBuilder, "Another random string");
  }
  </code></pre>
  
  <p>Here is the code for the text downloader:</p>
  
  <pre><code>public static void SaveStringToTextFile(StringBuilder data, String fileName)
      {
          HttpContext.Current.Response.Clear();
          HttpContext.Current.Response.Buffer = true;
          HttpContext.Current.Response.Charset = "";
          HttpContext.Current.Response.ContentType = "application/text";
          HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + fileName + ".txt");
          HttpContext.Current.Response.Output.Write(data.ToString());
          HttpContext.Current.Response.Flush();
          HttpContext.Current.Response.SuppressContent = true;
          HttpContext.Current.ApplicationInstance.CompleteRequest();
  
              return true;
         }
  </code></pre>
  
  <p>And here is the code for the javascript alert:</p>
  
  <pre><code>public static void MessageToUser(Page page, string mensaje)
      {
          ScriptManager.RegisterStartupScript(page, page.GetType(), "message", "alert('" + mensaje + "')", true);
      }
  </code></pre>
  
  <p>Thanks in advance.</p>