My function btnDownloadArchives_Click well summarized.
protected void btnDownloadArquivos_Click(object sender, EventArgs e)
{
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename= " + nomeArquivo);
Response.CacheControl = "Private";
//Aqui dentro tem uma outra função qualquer.
Response.Flush();
Response.Clear();
Response.ClearContent();
HttpContext.Current.ApplicationInstance.CompleteRequest();
EscreveErroNaTela();
}
Inside the WriteErnaNaTel () function has the following code.
ScriptManager.RegisterClientScriptBlock(this, GetType(), "Alerta", "alert('Alguns arquivos não puderam ser baixados. Clique no botão erros para maiores informações');", true);
This code ScriptManager.RegisterClientScriptBlock works fine, the problem is that in the function btnDownload_ClickArchives has some conditions, and when entering this condition it fills some Response properties, after a Flush, Clear, Clear content.
When it fills these properties my ScriptManager does not work, no alert is displayed, what may be happening?