C # The js method called in the background is ineffective and cannot be solved .,
This. Page. ClientScript. RegisterStartupScript (this. Page. GetType (), "", "<script> Ceshi (); </script>", true );
This code is put together with the following code. No matter where it is inserted, this code is invalid and cannot call js.
Comment out
Page. Response. Clear ();
Page. Response. AppendHeader ("Content-Disposition", "attachment; filename =" + HttpUtility. UrlEncode (Path. GetFileName (filepath), System. Text. Encoding. UTF8 ));
Page. Response. AppendHeader ("Content-Length", fiOutFile. Length. ToString ());
You can call js, but the following excel export code is abnormal.
Solving ....
FileInfo fiOutFile = new FileInfo (filepath );
Page. Response. Clear ();
Page. Response. ClearHeaders ();
Page. Response. Buffer = false;
Page. Response. AppendHeader ("Content-Disposition", "attachment; filename =" + HttpUtility. UrlEncode (Path. GetFileName (filepath), System. Text. Encoding. UTF8 ));
Page. Response. AppendHeader ("Content-Length", fiOutFile. Length. ToString ());
Page. Response. WriteFile (fiOutFile. FullName );
FiOutFile. Delete ();
Page. Response. Flush ();
Page. Response. End ();