How do I prevent button presses until form request is completed when form request causes a file download
<p>In my Asp.net webforms site I have a form where users select various options and those options are sent back in a postback that generates a PDF report and sends that file back to the user for download via the following code:</p>

<pre><code>    protected void btnTopGenReport_Click(object sender, EventArgs e)
    {
        var stream = new PodMainReportGenerator().GenerateReport(GetReportParameters());

        var bytes = stream.ToArray();
        stream.Close();

        // Set the content headers
        Response.Clear();
        Response.Buffer = true;
        Response.ContentType = "application/pdf";
        Response.AddHeader("Content-Disposition", "attachment;filename=testReport.pdf");
        Response.AddHeader("Content-Length", bytes.Length.ToString());

        Response.BinaryWrite(bytes);

        Response.End();
    }
</code></pre>

<p>The problem is this report can take a good 10 or so seconds to generate due to the amount of data and processing required, but I don't want people getting impatient and clicking the button over and over again.</p>

<p>In a normal page I would add javascript to disable the buttons on click.  This works because when postback is complete the server comes back with the form buttons re-enabled.  However, since the form's response is not an HTML page but a downloaded file, which I don't know how to detect.</p>

<p>Essentially, how do I disable the form's buttons but re-enable them once we get the response from the server (and the http file transfer is initiated)?</p>
