There are many similar questions, but there is still no clear answer that solves the problem by taking some action after writing the thread for the answer.
I have the following situation:
At the click of a button, I generate some excel file, which I am going to write in response, allowing the user to load the generated file. Imidietly after clicking a button, I turn it off to prevent this button from double-clicking. In the page-Load event handler, I have the following code:
GenerateBTN.Attributes.Add("onclick", "this.disabled=true;" + ClientScript.GetPostBackEventReference(GenerateBTN, "").ToString());
After the Page_Load EventHandler, the GenerateBTN_Click handler executes the code needed to generate the file and at the end of this method (handler) I reply to the generated file using the following code:
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
Response.WriteFile(@"C:\Reports\" + filename);
Response.End();
" ", , , GenerateBTN . afer ? , afer , , ?