So I know that this is common problem, page freezes (any buttons visually are clickable but doesn't perform any action) because it doesn't close some request after file download.
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.ClearContent(); response.Clear(); response.ContentType = "text/txt"; response.AddHeader("Content-Disposition", "attachment; filename=" + TreeView1.SelectedNode.Text + ";"); response.TransmitFile(TreeView1.SelectedNode.Value); response.Flush(); response.Close(); HttpContext.Current.ApplicationInstance.CompleteRequest();
This code is in TreeView
SelectedNodeChanged event, and this is a problem.
For example if will put that transmit code in some button, I can fix freezing of page by adding
But I don't know how to fix this if I'm clicking on TreeView node. TreeView doesn't have
OnClientClick, I also tried to run that JS function from code behind right before and after transmit code
Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "setFormSubmitToFalse()", true);
but it doesn't help, page is still freezing after file download.
Any ideas how can I fix this? Thanks.