469,282 Members | 1,822 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

Export to Excel clobbers browser history (sometimes)

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

Mar 6 '07 #1
1 2308
On Mar 6, 5:11 pm, "Randy" <randystephen...@gmail.comwrote:
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

Mar 7 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by frankvfox | last post: by
1 post views Thread by Matt | last post: by
4 posts views Thread by Anthony Cuttitta Jr. | last post: by
1 post views Thread by Kevin Blakeley | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.