ReportViewer is undefined JavaScript error.
Environment
Product | Progress® Telerik® Reporting |
Report Viewers | ASP.NET WebForms Report Viewer |
This article relates only to the Legacy Report Viewer. You may be looking for HTML5 Report Viewer Troubleshooting
Description
The following JavaScript error is thrown, when opening a page containing the ASP.NET WebForms Report Viewer.
Error Message
'ReportViewer' is undefined.
Possible Cause
This error usually indicates that the ReportViewer control has not been able to load its resources for some reason - JavaScript, CSS and images.
Solution
- Missing preCondition attribute of the report viewer handler's registration in the <system.webServer><handlers> section, when the application is hosted on IIS7, i.e. the handler should look like this:
<system.webServer>
<handlers>
<add name="Telerik.ReportViewer.axd_*" path="Telerik.ReportViewer.axd" verb="*" type="Telerik.ReportViewer.WebForms.HttpHandler, Telerik.ReportViewer.WebForms, Version=x.x.x.x, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" preCondition="integratedMode" />
</handlers>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
Try changing the application pool between DefaultAppPool and Classic .Net AppPool.
Remove/disable compression modules (if any) as they may somehow interfere with the viewer's handler.
-
Run the application, open a new tab in the browser and directly request the viewer's resource by using the following url:
http://devmachine/MyApplication/Telerik.ReportViewer.axd?name=Resources.ReportViewer.js&optype=Resource&version=x.x.x.x
This should give more detailed information about the error.
-
If authorization is used, it is possible that this somehow restricts the access to the HTTP handler used by the viewer. Please, add the following <location> element to your web.config to make sure the handler is accessible at all times:
<location path="Telerik.ReportViewer.axd"> <system.web> <authorization> <allow users="*"/> </authorization> </system.web> </location>
The error may also occur if you're trying to reference the viewer's client-side object prior to the control registration on the page i.e:
<script type="text/javascript">
var viewer = <%=ReportViewer1.ClientID%>
</script>
<telerik:reportviewer id="ReportViewer1" runat="server"></telerik:reportviewer>
If you are still having problems, please use a web debugging proxy (e.g. Fiddler Jam) and check what is the response for the /ReportViewer.axd?name=Resources.ReportViewer.js&version=x.x.x.x&optype=Resource request or any request of such kind.
Substitute Version=X.X.X.X with the exact assembly version you are using!