I have a page which exports a document to excel on button click. What I need to do is refresh the page after the excel document has been sent.
I am trying to register a script which will cause a page refresh but cant get it to register at the same time as exporting to excel.
ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "test", "alert('Done');", True)
Response.Clear()
Response.ClearHeaders()
Response.AddHeader("Refresh", "3; url=" + Request.RawUrl)
Response.ContentType = strMimeType
Response.AddHeader("content-disposition", "attachment; filename=CompleteReport." + strFilenameExtension)
Response.BinaryWrite(bytFileContent)
Response.End()
You can make
only one response for each requests
(first excel export, and the second would be the refresh).
After first response.end, you can’t do anything.
You have to solve the excel export another way, with component etc.
And after export you can call