473,324 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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 2461
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: frankvfox | last post by:
I need a code sample using VB ASP.Net 2003 which exports a tab delimited text file resident on the server into an Excel spreadsheet which will be saved through the browser to the client's local...
1
by: Matt | last post by:
I have an ASP page that calls ASP routines that I created that execute a database query and return the results to a recordset. I then iterate through the recordset and display the data in a table....
4
by: Anthony Cuttitta Jr. | last post by:
I'm working on some procedures where Access queries are exported to Excel, and then later on, those same workbooks are openned, and I need to target a specific original sheet. Sometimes there will...
1
by: Jim | last post by:
This should really be simple, but I can't figure it out. I have some VB that exports a table in an Excel format ("C:\NewReport.xls"). After the export is done, I simply want to have some code...
1
by: Benny Ng | last post by:
Hi,All, Export Method: ------------------------------------------------------------------------- strFileNameExport = "Results" Response.Clear() Response.Buffer = True...
1
by: Kevin Blakeley | last post by:
I know this was just posted but I did not want this message to get lost in the other thread as it's slightly different. Yes I want to export my dataset to excel for my clients, but I don't want...
7
by: mattmerc | last post by:
Hi all, We have all seen lot of method for exporting datagrids to Excel. I have a slightly different need. I think it should be easy to accomplish but I am not sure how. I would like when a user...
1
by: RobinAG | last post by:
Hello, I'm trying to create a new Excel document from a template I've created (Export.xls). I'm having trouble getting it to work, sometimes it works, sometimes it gives me a run-time error '70',...
7
Merlin1857
by: Merlin1857 | last post by:
Its great producing data for users to look at in your web pages and generally that is sufficient for their needs but sometimes you may want to supply your user with the data in a form they can...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.