檢查ReportViewer JavaScript後,我想出了以下解決方案。如果微軟改變這種特殊方法,很容易破壞事情。以下代碼將被添加到頁面的頁眉中,以確保它在ReportViewer JavaScript加載後運行,但在創建RSClientController實例之前運行。
// This replaces a method in the ReportViewer javascript. If Microsoft updates
// this particular method, it may cause problems, but that is unlikely to
// happen.The purpose of this is to redirect the user to the error page when
// an error occurs. The ReportViewer.ReportError event is not (always?) raised
// for Remote Async reports
function OnReportFrameLoaded() {
this.m_reportLoaded = true;
this.ShowWaitFrame(false);
if (this.IsAsync)
{
if(this.m_reportObject == null)
{
window.location =
'<%= HttpRuntime.AppDomainAppVirtualPath %>/Error.aspx';
}
else
{
this.m_reportObject.OnFrameVisible();
}
}
}
RSClientController.prototype.OnReportFrameLoaded = OnReportFrameLoaded;
從微軟的ReportViewer腳本文件中的原始代碼(Microsoft.ReportViewer.WebForms,裏面8.0.0.0,.Net框架3.5 SP1)是:
function OnReportFrameLoaded()
{
this.m_reportLoaded = true;
this.ShowWaitFrame(false);
if (this.IsAsync && this.m_reportObject != null)
this.m_reportObject.OnFrameVisible();
}
RSClientController.prototype.OnReportFrameLoaded = OnReportFrameLoaded;
你做了什麼異常? – 2009-09-18 03:58:36
Sproc報告中生成的自定義錯誤,但是這應該是無關緊要的,因爲我想處理這些錯誤,但沒有解決它們。 – 2009-09-18 05:47:55