Response.WriteFile stopping previous request
<p>I have a button that calls a click event to download a picture. In my click event I have some code to change my display as the Save dialog pops up. The issue I am having is that when the dialog comes up it stops the previous line of code from executing. How can I check to see that my code has executed before calling the function?</p>

<p>Here is my button event handler and function:</p>

<pre><code> protected void btnSave_Click(object sender, EventArgs e)
{
    var _title          = txtTitle.Text;
    txtTitle.Text       = string.Empty;
    txtDescription.Text = string.Empty;

    ChangeDisplay();

    if (Request.Browser.Browser == "IE")
        lblSnapShot.Visible = (lblSnapShot.Visible) ? false : true;

    SaveSnapShot(_title);
}

void SaveSnapShot(string _title)
{
    try
    {
        FileInfo _fileToDownload = new FileInfo(_path);
        Response.Clear();
        Response.ContentType = "image/png";
        Response.AppendHeader("Content-Disposition", "attachment; filename=\"" + _title + ".png\"");
        Response.WriteFile(_fileToDownload.FullName);

        HttpContext.Current.ApplicationInstance.CompleteRequest();
    }
    catch (System.Exception ex)
    {
        ChangeDisplay();

        if (Request.Browser.Browser == "IE")
            lblSnapShot.Visible = (lblSnapShot.Visible) ? false : true;

        Response.Write("SAVE FAILED \n Error: " + ex.Message);
    }
}
</code></pre>
