AJAX标记给出错误:Sys未定义

时间:2011-10-12 11:29:05

标签: asp.net asp.net-ajax asp.net-2.0

以下是我的母版页的代码。当我启用ScriptManager和相关标签(如下所示)时,IE会在调试时生成错误:Sys is undefined。当我禁用AJAX时,错误不会显示。无论显示的错误或未显示的错误,页面和相关代码都能正常工作。

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>

    <!-- Project CSS attachments -->
    <link href="Stylesheets/StyleSheet2.css" rel="stylesheet" type="text/css" />
    <link href="Stylesheets/ReportsMenu.css" type="text/css" rel="Stylesheet" />
    <link href="Stylesheets/StyleSheet.css" rel="stylesheet" type="text/css" />
    <link href="Stylesheets/TubewellReportsMenu.css" rel="stylesheet" type="text/css" />

    <!-- JQuery Core attachment -->
    <link href="Resources/JQueryScripts/Core/jquery-1.6.4.min.js" type="text/javascript" />    
    <link href="Resources/JQueryScripts/Core/jquery.min.js" type="text/javascript" />

    <!-- JQuery MSG Plugin library attachments -->
    <link href="Resources/JQueryScripts/MsgPlugin/jquery.center.min.js" type="text/javascript" />    
    <link href="Resources/JQueryScripts/MsgPlugin/jquery.msg.js" type="text/javascript" /> 
    <link href="Resources/JQueryScripts/MsgPlugin/jquery.msg.min.js" type="text/javascript" />
    <link href="Resources/JQueryScripts/MsgPlugin/jquery.msg.css" rel="Stylesheet" type="text/css" />                   

    <!-- JQuery Message Box Library attachments -->
    <link href="Resources/JQueryScripts/MsgBox/jquery.dragndrop.min.js" type="text/javascript" />            
    <link href="Resources/JQueryScripts/MsgBox/jquery.msgbox.js" type="text/javascript" />            
    <link href="Resources/JQueryScripts/MsgBox/jquery.msgbox.css" type="text/javascript" />            
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    <div runat="server">
            <div class="TopBand" runat="server">
                <asp:LinkButton ID="LinkButton1" runat="server" PostBackUrl="~/Default.aspx" >Home</asp:LinkButton>&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:LinkButton ID="lbAdministration" runat="server" PostBackUrl="~/Admin.aspx" >Administration</asp:LinkButton>&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:LinkButton ID="LinkButton2" runat="server" PostBackUrl="~/pheTubewellFiles/contentReportTubewellMenu.aspx">Tubewell Reports</asp:LinkButton>&nbsp;&nbsp;&nbsp;&nbsp;                
                <asp:LinkButton ID="lbReports" runat="server" PostBackUrl="~/pheSchemeFiles/contentReportSchemesMenu.aspx">Scheme Reports</asp:LinkButton>&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:LinkButton ID="lbRegister" runat="server" PostBackUrl="~/pheSchemeFiles/contentReportAllSchemeTypes.aspx">Register</asp:LinkButton>&nbsp;&nbsp;&nbsp;&nbsp;
            </div>

            <div id="divContentPlaceHolder" runat="server" class="ContentPlaceHolder">
                <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
                </asp:contentplaceholder>
            </div>
    </div>
    </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>
</html>

IE调试器中运行时显示的错误是:

enter image description here

为什么 ScriptManager 和相关的AJAX标记会出现此错误?

1 个答案:

答案 0 :(得分:1)

您正在使用<link>标记来包含javascript文件。它们应该包括在内:

<script type="text/javascript" src="script.js"></script>

您还有一个导入css文件的最后<link>个代码,但其类型设置为javascript:

<link href="Resources/JQueryScripts/MsgBox/jquery.msgbox.css" type="text/javascript" />

解决这些问题,其余的可能会有效吗?