I am implementing a export to excel functionality via ASP.net. i have a button control on a page. when i click the button, the control goes to the click event of the button. there i make a call to stored procedure to get the excel data. In Click event (codebeind) i have the below to code to download the data in excel file.
Response.Clear()
Response.AddHeader("content-disposition", String.Format("attachment;filename={0}.csv", "Report"))
Response.Charset = ""
Response.ContentType = "application/vnd.xls"
Response.Write("a,b,c") - sample output from SP.
Response.Flush();
All these works fine. the issue is - sometimes the procedure takes long time to execute, so in order to avoid the user messing up with UI untill the download starts, i have a javascript code to disable the UI when the download button is clicked. This is also working fine. but i am not able to call any javascript code to re-enable to UI, once the download has started or just before download starts. when i try to render a script before response.clear(in above code) and give response.flush, it gives me a error that i cannot change the response header once it is sent to client. how can i achieve this functionality?
Summary of question? i want to disable the UI from the time user has clicked on download button and till the actual download starts. once the download starts, i want to enable the UI back. How can i achieve this.
Thanks.