Microsoft JScript runtime error: 'Sys' is undefined

时光毁灭记忆、已成空白 提交于 2019-12-18 18:52:10

问题


I have a page with the following code on it:

<script type="text/javascript" language="javascript">
    /// <reference name="MicrosoftAjax.js" />

    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

    function EndRequestHandler(sender, args)
    {
        ToggleTimeDiv();
    }
</script>

When the page loads I get the following error:

  • Microsoft JScript runtime error: 'Sys' is undefined

I'm using Visual Studio 2008 Standard Edition. What is causing this error?


回答1:


Is your <script> block ahead of your ScriptManager?




回答2:


You should place your script code at the end of your page, after all your content but just before the end tag. between end form tag and end body tag Here’s the code you need, in its rightful place:

   <html>

  ...
   </head>
   <body>
    <form id="form1" runat="server">
     ...
    </form>


    enter code here
     <script type="text/javascript" language="javascript">
  /// <reference name="MicrosoftAjax.js" />

  Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

  function EndRequestHandler(sender, args)
  {
      ToggleTimeDiv();
  }
  </script>




   </body>
      </html>



回答3:


Do you have

<asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>

at the top of your page.. I had same problem.. added this and it works...




回答4:


If you're using ASP.NET routing, use this line in your global.asax

    void Application_Start(object sender, EventArgs e)
    {
       RouteTable.Routes.Ignore("{resource}.axd");
    }


来源:https://stackoverflow.com/questions/1931701/microsoft-jscript-runtime-error-sys-is-undefined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!