Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 在服务器端的ajax面板中的新窗口中打开链接_Asp.net_Ajax_Telerik - Fatal编程技术网

Asp.net 在服务器端的ajax面板中的新窗口中打开链接

Asp.net 在服务器端的ajax面板中的新窗口中打开链接,asp.net,ajax,telerik,Asp.net,Ajax,Telerik,我以前问过这个问题,但没有得到有效的答案 这是一个按钮单击事件,应启动下载: protected void btnDownload_Command1(object sender, CommandEventArgs e) { GridDataItem item = gvClients.Items[Convert.ToInt32(e.CommandArgument)]; GetUserData usr = new GetUserData(item["id"].Text, Securi

我以前问过这个问题,但没有得到有效的答案

这是一个按钮单击事件,应启动下载:

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面板的情况下向用户发送文件?

如果您的按钮位于ASP.NET Ajax更新面板中,您可以只关闭下载按钮的Ajax

ScriptManager.RegisterPostBackControl(btnDownload);

如果您使用的是Telerik Ajax控件,则可以使用以下代码弹出一个窗口

在Radajax面板之前,确保页面上有RadScriptManager和RadAjaxManager

然后在您的Radajax面板中添加一个RadWindowManager,如下所示

<telerik:RadWindowManager runat="server" ID="rwm" Modal="true" Skin="Default" AutoSize="true" />

根据需要调整DownLoadPopup.aspx的路径和RadWindow的属性。

我不久前用这个解决方案解决了这个问题:AjaxPanel1.RegisterStartupScript.add(myscript);不要创建服务器对象,它不是必需的,通过调用radopen(url,null)在客户端上创建一个空白RadWindow,请参见此处
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();

  rwm.Windows.Clear();
  var rWin = new RadWindow();
  rWin.ID = "Name of my window";
  rWin.NavigateUrl = string.Format("~/DownLoadPopup.aspx?file={0}", file);
  rWin.Width = Unit.Pixel(1000);
  rWin.Height = Unit.Pixel(600);
  rWin.VisibleOnPageLoad = true;
  rwm.Windows.Add(rWin);
}