Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/306.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
C# 在新窗口中打开SSRS报告_C#_Asp.net_Ssrs 2008 R2 - Fatal编程技术网

C# 在新窗口中打开SSRS报告

C# 在新窗口中打开SSRS报告,c#,asp.net,ssrs-2008-r2,C#,Asp.net,Ssrs 2008 R2,我使用C#创建了一个简单的ASP.NET页面,用户输入一个参数,点击一个按钮,然后运行一个SSRS报告并显示在网页中。但是,我希望报告在新窗口中打开,而不是嵌入到ASPX页面中 这是我现在的代码: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Micros

我使用C#创建了一个简单的ASP.NET页面,用户输入一个参数,点击一个按钮,然后运行一个SSRS报告并显示在网页中。但是,我希望报告在新窗口中打开,而不是嵌入到ASPX页面中

这是我现在的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        try
        {
            string AccountNumber = AcctNo.Text;
            ReportViewer.ProcessingMode = ProcessingMode.Remote;
            ReportViewer.ServerReport.ReportServerUrl = new Uri(@"http://johnssrsd04/ReportServer_SSRS2008DEV01");
            ReportViewer.ServerReport.ReportPath = "/Client Metrics POC/Reports/ClientMetricsDownload_POC";
            ReportViewer.ServerReport.Refresh();
            ReportParameter[] reportParameterCollection = new ReportParameter[1]; //Array size describes the number of paramaters.
            reportParameterCollection[0] = new ReportParameter();
            reportParameterCollection[0].Name = "paraAcctNo"; //Give Your Parameter Name
            reportParameterCollection[0].Values.Add(AccountNumber); //Pass Parametrs's value here.
            ReportViewer.ServerReport.SetParameters(reportParameterCollection);
            ReportViewer.ServerReport.Refresh();
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
}

有没有办法将其更改为在新窗口中打开SSRS报告?

下面是一种使用JavaScript的方法:

<asp:Button ID="Button2" runat="server" OnClientClick="openReport();"  Text="Open Report" />

<script>
    function openReport() {
        window.open("yourReportPage.aspx");
        return false;
    }
</script>

函数openReport(){
打开(“yourReportPage.aspx”);
返回false;
}

将按钮单击代码更改为加载事件。

此网站不是代码编写服务,也不是用于提供完整的解决方案。用户需要付出一些努力和编写一些代码,而SO将在这里帮助您解决具体的编程问题。你有没有试过让它像那样工作?