Export to Excel clobbers browser history (sometimes)

R

Randy

I have an application with a datagrid and a button to export the grid
to excel. For the most part this is working fine. Here's the export
method:

Private Sub btnExcel_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnExcel.Click
Try
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Page.EnableViewState = False

Dim oStringWriter As System.IO.StringWriter = New
System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New
System.Web.UI.HtmlTextWriter(oStringWriter)

Table1.RenderControl(oHtmlTextWriter)
MyDataGrid.RenderControl(oHtmlTextWriter)
oHtmlTextWriter.RenderBeginTag(HtmlTextWriterTag.P)
lblDataReflects.RenderControl(oHtmlTextWriter)
oHtmlTextWriter.RenderBeginTag(HtmlTextWriterTag.P)
lblConfidential.RenderControl(oHtmlTextWriter)
oHtmlTextWriter.RenderBeginTag(HtmlTextWriterTag.P)
lblCSISM.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString())
Response.End()
Catch ex As Exception
Throw New Exception("Error in btnExcel_Click event", ex)
End Try
End Sub


When the button is clicked the page is rendered in excel format. Then
when the back button is clicked it goes back to the html view, AND
click the back button again... and it goes back to the system menu
screen where it came from originally.

However, when there is a large amount of data (750 or so rows), the
excel rendered page's browser cache history only remembers the prior
page. Everything else is gone. Clicking the back button from the excel
view will display the html view again, but with a disabled back
button. So there is no way to 'back button' your way back to the
menu.

Anyone know why the browser history is getting clobbered? Again, it
only happens when there is a larger amount of data in the grid.

PLEASE!

Randy
 
R

Randy

I have an application with a datagrid and a button to export the grid
to excel. For the most part this is working fine. Here's the export
method:

Private Sub btnExcel_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnExcel.Click
Try
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Page.EnableViewState = False

Dim oStringWriter As System.IO.StringWriter = New
System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New
System.Web.UI.HtmlTextWriter(oStringWriter)

Table1.RenderControl(oHtmlTextWriter)
MyDataGrid.RenderControl(oHtmlTextWriter)
oHtmlTextWriter.RenderBeginTag(HtmlTextWriterTag.P)
lblDataReflects.RenderControl(oHtmlTextWriter)
oHtmlTextWriter.RenderBeginTag(HtmlTextWriterTag.P)
lblConfidential.RenderControl(oHtmlTextWriter)
oHtmlTextWriter.RenderBeginTag(HtmlTextWriterTag.P)
lblCSISM.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString())
Response.End()
Catch ex As Exception
Throw New Exception("Error in btnExcel_Click event", ex)
End Try
End Sub

When the button is clicked the page is rendered in excel format. Then
when the back button is clicked it goes back to the html view, AND
click the back button again... and it goes back to the system menu
screen where it came from originally.

However, when there is a large amount of data (750 or so rows), the
excel rendered page's browser cache history only remembers the prior
page. Everything else is gone. Clicking the back button from the excel
view will display the html view again, but with a disabled back
button. So there is no way to 'back button' your way back to the
menu.

Anyone know why the browser history is getting clobbered? Again, it
only happens when there is a larger amount of data in the grid.

PLEASE!

Randy

Let me ask it another way. What might cause the history cache to drop
URLs, thus disabling the back button. Could something be causing a
page to expire? This makes no sense to me, and in spite of all my
searching I can't find someone who has had the same problem.

I've seen tons of articles about how to go about disabling the back
button. I have the reverse problem.

Anyone?

Randy Stephenson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top