I have an aspx page with a grid and a linkbutton. When clicking on this linkbutton I call a function that locks the screen and places a loading while downloading a file on the server, after download I try to call the function to unlock the screen, but it does not call because the response has already been finalized. I tried to perform via iframe but I do not know how to send that same file to be downloaded in the iframe.
Follow my codes.
When I click on the grid linkbutton
Script code
$('#meugrid').find('a').click(function () { ForceBlock(); });
Linkbutton code in codebehind
protected void linkbtn_Click(object sender, EventArgs e)
{
LinkButton lb = (LinkButton)sender;
int id = Convert.ToInt32(lb.CommandArgument);
FileInfo arquivo = new FileInfo("meuarquivo");
string path = @"meucaminho\";
File.WriteAllBytes(path + arquivo.FileName, arquivo);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment; filename=" + arquivo.FileName);
Response.AddHeader("Content-Length", arquivo.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.TransmitFile(path + arquivo.FileName);
Response.Flush();
Response.Close();
HttpContext.Current.ApplicationInstance.CompleteRequest();
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "scriptUnblock", "ForceUnblock()", true);
}