Export GridView to Excel error
Posted on 2007-08-06
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.AddHeader("content-disposition", "attachment; filename=Marketing Tracker Export.xls")
Response.ContentType = "application/vnd.ms-excel"
Me.EnableViewState = False
Response.Charset = String.Empty
Dim myTextWriter As New System.IO.StringWriter
Dim myHtmlTextWriter As New System.Web.UI.HtmlTextWriter(myTextWriter)
The code above has worked fine for me when used on a page that was not instanced from a master page. Now when i use it i get the following 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 <div>