?
Solved

Export GridView to Excel error

Posted on 2007-08-06
4
Medium Priority
?
1,098 Views
Last Modified: 2012-05-05
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)
            gvFB.RenderControl(myHtmlTextWriter)
            Response.Write(myTextWriter.ToString())
            Response.End()

        End Sub

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>
                                                   <table cells
0
Comment
Question by:zx10r
  • 2
  • 2
4 Comments
 
LVL 3

Expert Comment

by:sr22ger
ID: 19640559
Are you sure this is necessarily caused by Master Pages and not asp.net ajax?  This seems like the error you get if you modify the page after the initial load using Response.Write('some html code').
0
 
LVL 4

Author Comment

by:zx10r
ID: 19640640
Yes that could very well be too. any idea on how i go about resolving this?
0
 
LVL 3

Accepted Solution

by:
sr22ger earned 2000 total points
ID: 19640723
Is the submit button inside the update panel used in your ajax?  If it is, try to place it outside the update panel so the postback is not being done asynchronously.
0
 
LVL 4

Author Comment

by:zx10r
ID: 19640845
That did it!!! Thanks very much for the help.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month16 days, 7 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question