使用visual studio 2012.我需要在我的网页中的div中加载我的报表查看器。但它会是空白的。它可以单独使用一个单独的网页,但是当我想将它加载到我的内容页面内的一个部分时,它是空白的。我的代码部分与报表查看器一起使用:
// add a div dynamically
HtmlGenericControl div = new HtmlGenericControl("div");
div.Attributes.Add("id", "chart05");
div.Attributes.Add("runat", "server");
div.Attributes["class"] = "chartItem";
sanaChartsContainer.Controls.Add(div);
Microsoft.Reporting.WebForms.ReportViewer viewer = new Microsoft.Reporting.WebForms.ReportViewer();
viewer.Attributes.Add("id", "ReportViewer");
viewer.Attributes.Add("runat", "server");
viewer.Attributes.Add("Font-Names", "Verdana");
viewer.Attributes.Add("Font-Size", "8pt");
viewer.Attributes.Add("Height", "50px");
viewer.Attributes.Add("ProcessingMode", "Remote");
viewer.Attributes.Add("WaitMessageFont-Name", "Verdana");
viewer.Attributes.Add("WaitMessageFont-Size", "14pt");
viewer.Attributes.Add("Width", "50px");
viewer.Attributes.Add("AsyncRendering", "false");
viewer.ServerReport.Refresh();
viewer.ShowParameterPrompts = false;
Uri baseUri = new Uri("http://mdb165.cbi.net/reportserver");
viewer.ServerReport.ReportServerUrl = baseUri;
viewer.ServerReport.ReportPath = "/SanaII/report005";
System.Web.UI.ScriptManager scriptManager = new ScriptManager();
Page page = new Page();
System.Web.UI.HtmlControls.HtmlForm form = new HtmlForm();
//div.Controls.Add(scriptManager);
div.Controls.Add(viewer);
我的网络配置是:
<configuration>
<system.web>
<compilation debug="true">
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
</buildProviders>
</compilation>
<httpHandlers>
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" validate="false"/>
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
</handlers>
</system.webServer>
</configuration>
我还在页面中添加了脚本管理器, 但报告查看器是空白的。
我还尝试将其直接加载到我的内容页面中,如下所示:
但这也不起作用并且是空白的。 请帮我。
答案 0 :(得分:0)
您是否尝试在Page_Load中添加 if(!IsPostBack)?
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SetDate();
BindCustomerCategory();
BindUtility();
}
}
或者如果这不起作用。仔细检查报告页面的aspx,你可能会忘记那里的东西..