So, I know that this is a common problem, the page freezes (any buttons are visually clickable, but do not perform any actions), because they do not close any request after downloading the file.
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 the TreeView event SelectedNodeChanged, and that is the problem.
For example, if you put this transfer code in some button, I can fix the page freeze by adding OnClientClick="javascript:setFormSubmitToFalse()"to the button, and this small JavaScript patch page is fixed after loading.
<script type="text/javascript">
function setFormSubmitToFalse() {
setTimeout(function () { _spFormOnSubmitCalled = false; }, 3000);
return true;
}
</script>
, , TreeView node. TreeView OnClientClick, JS , Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "setFormSubmitToFalse()", true);
, , .
, ? .
- ( asp.net) sharepoint.
Edit:
, .
, : , , , , , .
SQL, . - treeview SelectedNodeChanged,
SPSecurity.RunWithElevatedPrivileges(delegate()
{
});
, , - , , , TransmitFile , JS , OnClientClick.
, , , treeview qaru.site/questions/126019/...