Microsoft JScript runtime error: ‘Sys’ is undefined

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?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Is your <script> block ahead of your ScriptManager?

Method 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>

Method 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…

Method 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");
    }


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x