Javascript Microsoft JScript 运行时错误:“Sys”未定义
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1931701/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Microsoft JScript runtime error: 'Sys' is undefined
提问by Achilles
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 标准版。是什么导致了这个错误?
回答by ACP
Is your <script>block ahead of your ScriptManager?
您的<script>块是否领先于您的 ScriptManager?
回答by Eng. Osama Badarneh
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>
回答by SerenityNow
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...
在您页面的顶部.. 我遇到了同样的问题.. 添加了这个并且它有效......
回答by p.campbell
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");
}

