Download Now (V3) [your_file_ready_to_download] \/\/FREE\\\\
I have a C# program which will be used to download a generated word document. Also, after generating it, the 'Hour Glass' property in UI has to be reset to default. For that I am calling one javascript function using scriptmanager, which can be executed only if the statement appears at the last. Unfortunately, a step before there is a code to download the word document. when it happens, the program gets lost and never goes back and execute the remaining part of the program in which the script manager is present to stop the hourglass. Putting script manager ahead of the downloading code also wont help. I suffer a lot from this peculiar problem. Please help, Thank you!!
Download Now (V3) [your_file_ready_to_download]
When Response.End() is called, you will no longer get a response back from the server because Response.End() throws an exception by nature and you can do nothing about it. What you need to do is switch the order. Once you have your file ready to download, use ScriptManager to register a script that does __doPostBack with a particular argument. Later in Page_Load you will read that argument and execute the download accordingly. Meanwhile, after ScriptManager.RegisterStartupScript (or ScriptManager.RegisterClientScriptBlock), Do your clean up logic.
Now your next question will be: Is that the 'neatest' possible way to do it? Basically, if you insist on having everything on the same page then yes you'll have to implement such a workaround. However, the general trend is to open up another tab (new page) that only does the download. One popular example is Microsoft website. Check how you download .NET Framework here. 041b061a72