title: Response.End() generates an error when exporting gridview to excel file
body: <p>I have this code:</p>
  
  <pre><code>protected void ibtGenerateReport_Click(object sender, ImageClickEventArgs e)
  {
      string filename = "report.xls";             
  
      StringWriter stringWriter = new StringWriter();
      HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWriter);
      DataGrid DataGrd = new DataGrid();            
      DataGrd.DataSource = odsLSRAudit;
      DataGrd.DataBind();
  
      DataGrd.RenderControl(htmlWrite);            
  
      System.IO.StreamWriter vw = new System.IO.StreamWriter(filename, true);
      stringWriter.ToString().Normalize();
      vw.Write(stringWriter.ToString());
      vw.Flush();
      vw.Close();
      WriteAttachment(filename, "application/vnd.ms-excel", stringWriter.ToString());           
  }
  
  public static void WriteAttachment(string FileName, string FileType, string content)
  {
      HttpResponse Response = System.Web.HttpContext.Current.Response;
      Response.ClearHeaders();
      Response.AppendHeader("Content-Disposition", "attachment; filename=" + FileName);
      Response.ContentType = FileType;
      Response.Write(content);            
      Response.End();
  }
  </code></pre>
  
  <p>But the <code>Response.End()</code> gives me the below error:</p>
  
  <p><code>Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
  Details: Error parsing near '&lt;table cellspacing="'.</code></p>
  
  <p>The <code>Response.Write(content)</code> has the correct information as I can see. But no Save/Open dialog box appear, besides the above error.</p>
  
  <p>I'm using UpdatePanels.</p>