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?
Is your <script>
block ahead of your ScriptManager?
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>
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...
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");
}