views:

11121

answers:

17
+3  Q: 

Sys is undefined

I have an ASP.Net/AJAX control kit project that i am working on. 80% of the time there is no problem. The page runs as it should. If you refresh the page it will sometimes show a javascript error "Sys is undefined".

It doesn't happen all the time, but it is reproducible. When it happens, the user has to shut down their browser and reopen the page.

This leads me to believe that it could be an IIS setting.

Another note. I looked at the page source both when I get the error, and when not. When the page throws errors the following code is missing:

<script src="/ScriptResource.axd?d=EAvfjPfYejDh0Z2Zq5zTR_TXqL0DgVcj_h1wz8cst6uXazNiprV1LnAGq3uL8N2vRbpXu46VsAMFGSgpfovx9_cO8tpy2so6Qm_0HXVGg_Y1&amp;t=baeb8cc" 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>
A: 

I have seen this happen on occasion if you do weird things with the Response object, but I don't think that's your issue here...

Grank
+1  A: 

Try setting your ScriptManager to this.

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
Compulsion
It is refreshing to get a different answer then the usual ones. I look forward to trying this out, i will let you know if it works.
ok, i had script manager already, but what i was noticing was the enablepartialrendering which was set to false for me, though setting it to true didn't fix my problem.FYI, i also have combinescripts set to true also.
Didn't work for me either..
Ric Tokyo
+3  A: 

In addition to ensuring you have the ScriptManager on your page you need to ensure that your web.config is appropriately configured.

When ASP.NET AJAX 1.0 was released (for .NET 2.0) there was a lot of custom web.config settings which added handlers, controls, etc.

You'll find the config info here: http://www.asp.net/AJAX/documentation/live/ConfiguringASPNETAJAX.aspx

Slace
A: 

I think you have just to make sure your javascript starts after the loading of the page "Sys is undefined" error means that Sys is not yet loaded ;)

kentaromiura
No that's not what's going on here -- Read his question. Sys will never be loaded because those includes are missing on the page. The question is why those script includes were not rendered on that page.
Clyde
A: 

Make sure that any client scripts you have that interact with .NET AJAX have the following line at the end:

if (typeof(Sys) !== 'undefined')  Sys.Application.notifyScriptLoaded();

This tells the script manager that the whole script file has loaded and that it can begin to call client methods

Tom Carter
A: 

I was having this same issue and after much wrangling I decided to try and isolate the problem and simply load the script manager in an empty page which still resulted in this same error. Having isolated the problem I discovered through a comparison of my site's web.config with a brand new (working) test site that changing <compilation debug="true"> to <compilation debug="false"> in the system.web section of my web.config fixes the problem.

I also had to remove the <xhtmlConformance mode="Legacy"/> entry from system.web to make the update panel work properly. Click here for a description of this issue.

MadMax1138
A: 

Was having a similar issue, except that my page was consistently generating the Sys is undefined error.

For me the problem stems from the fact that I've just installed the AJAX 1.0 extension for .NET 2.0 but had already created my web project in Visual Studio.

When tried to create AJAX controls I kept encountering this error, I spotted Slace's and MadMax1138s posts here. And figured it was my web.config, I created a new project using the new "AJAX enabled web site" project type, and sure enough the web.config has a large number of customizations necessary to use the AJAX controls.

I just updated that web.config with the web.config updates I had already made myself and dropped it into my existing project and everything worked fine.

TygerKrash
+3  A: 

I fixed my problem by moving the <script type="text/javascript"></script> block containing the Sys.* calls lower down (to the last item before the close of the body's <asp:Content/> section) in the HTML on the page. I originally had my the script block in the HEAD <asp:Content/> section of my page. I was working inside a page that had a MasterPageFile. Hope this helps someone out.

Dean L
A: 

Thanks Dean L. Simple yet perfect answer. You answer worked for me. Thanks a lot.

siva
+1  A: 

When I experienced the errors

  • Sys is undefined
  • ASP.NET Ajax client-side framework failed to load

in IE when using ASP.NET Ajax controls in .NET 2.0, I needed to add the following to the web.config file within the <system.web> tags:

<httpHandlers>
  <remove verb="*" path="*.asmx"/>
  <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  <add verb="GET" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler" validate="false"/>
</httpHandlers>
Ray Vega
A: 

Please please please do check that the Server has the correct time and date set...

After about wasting 6 hours, i read it somewhere...

The date and time for the server must be updated to work correctly...

otherwise you will get 'Sys' is undefined error.

Arsalan
A: 

April 15 i hav this problem but when i see ur post about server date i correct my date i resolve this ISSUE THANKS BUDDY ALot

faisal Motan
A: 

Just create blank .axd files in your solutions root foder problem will be resolved. (2 file: scriptresouce.asx, webresource.asxd)

kaash
A: 

I have been seeing the exact same error today, but it was not a config or direct JavaScript issue.

An external .net project had been updated but the changes not picked up properly in the compilation of the web site. My presumption is that ASP.NET ajax was not able to construct the client representations of the .NET objects properly and so was failing to load correctly.

To resolve, I rebuilt the external project(s), and rebuilt my solution that was experiencing issues. The problem went away.

BombDefused
A: 

Setting debug to false worked for me. Thanks MadMax, I'd vote except my reputation isn't high enough. :)

Inturbidus
A: 

Hi thanx a lot it solved my issue ,

By default vs 2008 will add

-->

Need to correct Default config(Above) to below code FIX

Anish