62,046
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="IE=EmulateIE7" http-equiv="X-UA-Compatible">
<title>Untitled Page</title>
</head>
<body>
<form id="MyForm" runat="server"><div id="Main">
<div id="NowMenu">
<div id="NowButton">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Loading" />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Loading" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
</div>
<asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<div id="loader_container">
<div id="loader">
<div style="text-align:center;"><img alt="loading" style=" vertical-align:middle; margin-right:8px;" src="/Template/Image/loading.gif" />数据载入中,请稍后……</div>
<div id="loader_bg"><div id="progress"></div></div>
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</div>
</form>
</body>
</html>
protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
}
public void Button2_Click(object sender, EventArgs e)
{
string Sql = " Where [StatUs]=0 And [State] !='D' And [Position] = 'C' ";
GetContent(Sql, DateTime.Now.AddDays(-1).ToString("yyyyMMdd"));
}
/// <summary>
/// 下载文件,文件名重写,以数据流形式写入
/// </summary>
/// <param name="FileName">文件名</param>
/// <param name="FileContent">文件内容</param>
/// <returns>无</returns>
public static void DownloadExport(string FileName, string FileContent)
{
byte[] txtcontent = Encoding.Default.GetBytes(FileContent);
try
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Charset = "utf-8";
HttpContext.Current.Response.Buffer = false;
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(FileName)));
HttpContext.Current.Response.AppendHeader("Content-Length", txtcontent.Length.ToString());
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.BinaryWrite(txtcontent);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Close();
HttpContext.Current.Response.End();
}
catch (Exception ex)
{
throw (ex);
}
finally
{
txtcontent.Clone();
}
}