views:

2687

answers:

1

I've got a page using a Microsoft Reporting ReportViewer. The report appears to be working but the page is giving me two javascript errors, both of them "'Sys' is undefined".

Examining the html output, I can see that this page is not loading the ScriptResource.axd file. Here is the generated output from the <form runat="server">:

Normal pages:

<script src="/ScriptResource.axd?d=A7zLSiYT-QHoLdLnJ4qcSxAMYrwOyrYaDQLr4063d4z_oKYldDliKqXbyFe5lSU_BLW1XY7gevJ3qbD0cmlGqFb4n7TXEUowGbFVlAH6qW01&amp;t=ffffffff81a772fc" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');
//]]>
</script>

<script src="/ScriptResource.axd?d=A7zLSiYTQHoLdLnJ4qcSxAMYrwOyrYaDQLr4063d4z_oKYldDliKqXbyFe5lSU_pP3jafRTfoGWk6oNhALZysXq7AipBxlz6Hg1wbpmi5swSCq2gf8Ifthok9c1Qyjf0&amp;t=ffffffff81a772fc" type="text/javascript"></script>
<div>

<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"  
  value="/wEWBwLqzd6VBwLe87a+BQLe87a+BQKMhJXjCwLDhbnwDQLDhc2YCALFibnGClZTK/SWwK6x3zLDgngtDRWbwIkm" />
</div>

And here the page with a reportviewer control:

<script src="/Reserved.ReportViewerWebControl.axd?OpType=Resource&amp;Version=9.0.30729.1&amp;Name=Microsoft.Reporting.WebForms.Scripts.ReportViewer.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function RVClientImageToggle(shouldEnable, image1Id, image2Id)
{
var enableHover = document.getElementById(image1Id);
var disableHover = document.getElementById(image2Id);
if (enableHover == null || disableHover == null)
    return;
if (shouldEnable)
{
    enableHover.style.display = "";
    disableHover.style.display = "none";
}
else
{
    disableHover.style.display = "";
    enableHover.style.display = "none";
}
}//]]>
</script>

<div>
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWGQLrm7KJCwLe87a+BQLe87a+BQKMhJXjCwLDhbnwDQLDhc2YCALFibnGCgL4rMvOCQL4rK/NCQKp9KnKBgKp9I3JBgKQitCjCALzoZ6fCQLzoYKeCQLC2pe+DgLC2vu8DgKsmc6MBgLYo/6MDgKsz4boDQLCqZGDBgL97pJQAv3u/vQHAv3u6pkPAv3u1r4GAv3ugpYJAOTw7r3aR/RClkJpkBgvgn/NGjI=" />
</div>

There you can see -- no references to the axd files

The <ScriptManager> tag produces this in either case:

    <script type="text/javascript">
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('ctl00$ctl00$smManager', document.getElementById('aspnetForm'));
Sys.WebForms.PageRequestManager.getInstance()._updateControls([], [], [], 90);
//]]>
</script>

And that's where the javascript error comes in -- referencing the Sys object

So what is it that triggers the different output from <form runat="server">?

A: 

I still have no answer, but did find a workaround on the internet here: http://forums.asp.net/p/1318006/2617880.aspx#2617880

If I jam the report viewer into a user control, and then just have the user control on the page, the form tag will render correctly.

Note, I am using master pages as well so maybe that had something to do with this. The form tag is in the master page, then I have a content page with a user control in the content section, and then the ReportViewer in the user control. That works.

What didn't work was a master page with a form tag (runat=server), and a content page with a ReportViewer in the content section. That's the case in which none of the ASP.NET AJAX scripts were included, leading to 'Sys is undefined' errors.

Clyde