Javascript error : " 'Sys' is undefined "
I keep having an error when running my web application. The error does not cause a compilation error when on live server at least a javascript error and nothing else. But the real problem is when "debug" ... javascript error stops the compilation and I have to "Continue" three times before proceeding normally my debug. But this error occurs at every refresh the page. All this using Visual Studio.
After several 开发者_开发百科hours of search on google, I saw that it was a problem with the ScriptManager and Ajax. The real problem is that I do not use any Ajax on this page but the ScriptManager is on the masterpage. Worse still, on any other page on the website, that may use Ajax or not, no javascript error! Only THIS page cause this error! Any suggestion?
Note that I usualy talk french so there's probably error and sorry for this!
EDIT
There's the 3 places were compilation stop.
1. Sys.WebForms.PageRequestManager._initialize('ctl00$ctl08', document.getElementById('aspnetForm'));
2. Sys.WebForms.PageRequestManager.getInstance()._updateControls([], [], [], 90);
3. Sys.Application.initialize();
Make sure you include the asp.net-ajax script manager control on your pages.
Update:
From the comment:
But ONE page which do not use Ajax or anything relativly to the scriptmanager cause this error.
Wrong. The scriptmanager control causes a bunch of javascript to be included (<link ..>
-ed) in your rendered html page. Without that scriptmanager control, this javascript won't be available. Among the linked javascript is the Sys
object that your error is complaining about. The only way you get the Sys is undefined
error is if you have javascript for your page that in some way tries to use the Sys
object (perhaps via a third part control?). So I promise you, you are using "Ajax or [something related]."
However, you said you included a scriptmanager on your master page, and that should have been good enough. The most common reasons for this to be missing are that your scriptmanager control is missing or that you execute javascript that needs it before the javascript engine has imported it. So check again and make sure 1) that the page in question isn't somehow "special" in that it doesn't use the master page, and 2) that you don't have javascript running before the asp.net ajax scripts are imported.
This isn't an answer to your question, more of a suggestion for the future. I think Joel did a fine job of answering the question anyway.
For your sanity, get rid of that Microsoft AJAX. It's crap & it's not real AJAX anyway 'cause you're sending back the whole page anyway. It's just asynchronous.
Those meaningless & unnecessary "Sys is undefined" errors are part of the reason I abandoned Microsoft AJAX.
Move on to jQuery & MVC. It makes development fun again.
精彩评论