【发布时间】:2014-10-17 08:43:08
【问题描述】:
我以前问过这个问题,但没有得到有效的答案。
这是一个应该启动下载的按钮点击事件:
protected void btnDownload_Command1(object sender, CommandEventArgs e)
{
GridDataItem item = gvClients.Items[Convert.ToInt32(e.CommandArgument)];
GetUserData usr = new GetUserData(item["id"].Text, Security.level.Agent, servermap);
string file = usr.RetrieveContractPath();
SendFileDownload(file);
}
提供的解决方案之一是在新窗口中打开一个链接,并让页面加载窗口使用这段代码在那里启动下载:
protected void btnDownload_Command1(object sender, CommandEventArgs e)
{
GridDataItem item = gvClients.Items[Convert.ToInt32(e.CommandArgument)];
GetUserData usr = new GetUserData(item["id"].Text, Security.level.Agent, servermap);
string file = usr.RetrieveContractPath();
// SendFileDownload(file); dont call it here , call it in the other window
string url = "PopupFileDownload.aspx?file="+file;
string s = "window.open('" + url + "', 'popup_window', 'width=300,height=100,left=100,top=100,resizable=yes');";
ClientScript.RegisterStartupScript(this.GetType(), "script", s, true);
}
这不起作用。我尝试做类似的事情,因为我使用的是 Telerik Ajax 面板
ajaxPanel.ResponseScripts.Add("window.open('DownLoadPopup.aspx?file='" + file + "'', 'popup_window', 'width=300,height=100,left=100,top=100,resizable=yes');");
但这也不起作用。该命令被执行但没有任何效果。 如何在不牺牲 Ajax 面板的情况下向用户发送文件?
【问题讨论】: