Microsoft JScript运行时错误:'Sys'未定义

时间:2022-11-06 16:18:44

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
  • Microsoft JScript运行时错误:'Sys'未定义

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

我正在使用Visual Studio 2008标准版。导致此错误的原因是什么?

4 个解决方案

#1


36  

Is your <script> block ahead of your ScriptManager?

您的

#2


6  

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


4  

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


1  

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

如果您使用的是ASP.NET路由,请在global.asax中使用此行

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

#1


36  

Is your <script> block ahead of your ScriptManager?

您的

#2


6  

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


4  

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


1  

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

如果您使用的是ASP.NET路由,请在global.asax中使用此行

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