473,796 Members | 2,586 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.EventArg s) Handles btnExcel.Click
Try
Response.Clear( )
Response.Buffer = True
Response.Conten tType = "applicatio n/vnd.ms-excel"
Response.Charse t = ""
Page.EnableView State = False

Dim oStringWriter As System.IO.Strin gWriter = New
System.IO.Strin gWriter
Dim oHtmlTextWriter As System.Web.UI.H tmlTextWriter = New
System.Web.UI.H tmlTextWriter(o StringWriter)

Table1.RenderCo ntrol(oHtmlText Writer)
MyDataGrid.Rend erControl(oHtml TextWriter)
oHtmlTextWriter .RenderBeginTag (HtmlTextWriter Tag.P)
lblDataReflects .RenderControl( oHtmlTextWriter )
oHtmlTextWriter .RenderBeginTag (HtmlTextWriter Tag.P)
lblConfidential .RenderControl( oHtmlTextWriter )
oHtmlTextWriter .RenderBeginTag (HtmlTextWriter Tag.P)
lblCSISM.Render Control(oHtmlTe xtWriter)
Response.Write( oStringWriter.T oString())
Response.End()
Catch ex As Exception
Throw New Exception("Erro r 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 2489
On Mar 6, 5:11 pm, "Randy" <randystephen.. .@gmail.comwrot e:
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.EventArg s) Handles btnExcel.Click
Try
Response.Clear( )
Response.Buffer = True
Response.Conten tType = "applicatio n/vnd.ms-excel"
Response.Charse t = ""
Page.EnableView State = False

Dim oStringWriter As System.IO.Strin gWriter = New
System.IO.Strin gWriter
Dim oHtmlTextWriter As System.Web.UI.H tmlTextWriter = New
System.Web.UI.H tmlTextWriter(o StringWriter)

Table1.RenderCo ntrol(oHtmlText Writer)
MyDataGrid.Rend erControl(oHtml TextWriter)
oHtmlTextWriter .RenderBeginTag (HtmlTextWriter Tag.P)
lblDataReflects .RenderControl( oHtmlTextWriter )
oHtmlTextWriter .RenderBeginTag (HtmlTextWriter Tag.P)
lblConfidential .RenderControl( oHtmlTextWriter )
oHtmlTextWriter .RenderBeginTag (HtmlTextWriter Tag.P)
lblCSISM.Render Control(oHtmlTe xtWriter)
Response.Write( oStringWriter.T oString())
Response.End()
Catch ex As Exception
Throw New Exception("Erro r 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
3076
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 workstation. I don't need examples of a Windows application where everything is local. I've tried KB306022 which doesn't work. I've included references to Microsoft.Office.Core and Microsoft Excel 11.0 Object Library. When I try to use the...
1
5038
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. Before I iterate through the recordset I instruct the browser that the content type is Excel using the following line: (Response.ContentType = "application/vnd.ms-excel") This works fine with Excel 2003 but with older versions (I tested Excel...
4
3437
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 be multiple sheets in the same workbook, sometimes only a single tab. The issue is this: Save query "XLTest - qryExport" to file and the worksheet name becomes "XLTest___qryExport" (three underscores). I have a generic procedure which...
1
2896
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 that launches NewReport.xls in Excel. How?
1
3273
by: Benny Ng | last post by:
Hi,All, Export Method: ------------------------------------------------------------------------- strFileNameExport = "Results" Response.Clear() Response.Buffer = True Response.ContentType ="application/vnd.ms-excel" 'application/msword
1
3386
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 it to show in the browser. Everything I have tried makes it so that IE will load excel within the browser session and view the file in there. What I want is for the user to be prompted with the save dialog to save the excel file disk. How do I...
7
4916
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 clicks a button for exporting a datagrid, that the excel file is saved on the server and that it DOES NOT prompt the user to open or save. Here is the code I am using for standard export that prompts the user. Thanks all. Dim...
1
2139
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', permission denied. Here's the code I'm using: Dim appExcel As Excel.Application Dim wbk As Excel.Workbook Dim wks As Excel.Worksheet Dim CurrentDate As String Dim sWorkBook As String
7
28906
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 actually do something more with. This code shows you how to display data from your database and then how to give that data to the user in the form of a useable Excel spreadsheet which they can then take away and play with themselves. The way I have shown...
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10021
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9061
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7558
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5453
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4127
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.