Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Export opened in IE grays out back button

Status
Not open for further replies.

shankel

MIS
May 19, 2003
37
US
I am using the following code for an onclick event on my web app.

' Set the content type to Excel.
Response.ContentType = "application/vnd.ms-excel"

' Remove the charset from the Content-Type header.
Response.Charset = ""
' Turn off the view state.
Me.EnableViewState = False
Dim strw As New System.IO.StringWriter
Dim htmlw As New System.Web.UI.HtmlTextWriter(strw)
' Get the HTML for the control.
dg.RenderControl(htmlw)
' Write the HTML back to the browser.
Response.Write(strw.ToString())
' End the response.
Response.End()

When the user clicks it they prompted to save or open. When they choose open it opens in IE. If the dataset they are working with is large, it grays out the Back Button, so they can't get back to where they were. Anyone know if there is a way to fix this, or a way to allow save only, and not open. I can't seem to find the answer anywhere.

Thanks,
shankel
 
If they choose to open the file (which by the way is a client side attribute so you can't force them to either open or save the file as that is down to them) and if it is opening in a new window then they won't have a history and therefore can't go back a page. Is this the case?

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
It opens in the same window, which is the problem.
I did alter my code so that opens it in Excel instead of IE. Weird thing is, if you click open, it prompts you again, so you have to click it twice.

Dim fn
fn = "ExcelExport.xls"
' Set the content type to Excel.
Response.ContentType = "application/vnd.ms-excel"

'Open in Excel, instead of Internet Browser
Response.AddHeader("content-disposition", "attachment; filename=" & fn)
' Remove the charset from the Content-Type header.
Response.Charset = ""
' Turn off the view state.
Me.EnableViewState = False
Dim strw As New System.IO.StringWriter
Dim htmlw As New System.Web.UI.HtmlTextWriter(strw)
' Get the HTML for the control.
dg.RenderControl(htmlw)
' Write the HTML back to the browser.
Response.Write(strw.ToString())
'End the response.
Response.End()
 
Supposedly the dual prompt on Open, is an IE bug, but there's got to be a way around it.
 
Supposedly the dual prompt on Open, is an IE bug, but there's got to be a way around it.
I think it's called Firefox! [smile]

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top