ASP.NET AJAX 4.0 Live绑定 - 与Sys.registerComponent的问题

我正在尝试使用带有实时绑定的AJAX 4.0框架设计客户端模板。 我有定义名为VesselData的WCF服务(如果需要将提供代码),它返回一个名为VesselCollection的数据表类。另外,我在主文件中引用了以下脚本:MicrosoftAjax.debug.js,MicrosoftAjaxDataContext.debug.js,MicrosoftAjaxTemplates.debug.js。 问题是模板没有填满数据,dataContext上的fetchData方法转到failCallback方法,没有任何方法可以知道出了什么问题。此外,我在其中一个.js文件中的“Sys.registercomponent”上得到了几个javascript错误,如“对象不支持此属性或方法”。 请在这里需要一些帮助.. 码:
< %@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Vessels.aspx.cs" CodeFile="~/Vessels.aspx.cs" Inherits="SampleAJAXDatabinding.Vessels" %>

< %@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

< asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">


< script type="text/javascript">

    var dataContext = new Sys.Data.DataContext();
    dataContext.set_serviceUri("../Services/VesselData.svc");
    dataContext.initialize();

    function bind() {
        dataContext.fetchData("GetVesselData", { $top: 1 }, Sys.Data.MergeOption.overwriteChanges, "GET", function () { document.getElementById("template").style.display = "block"; alert('fetch succeeded.'); }, function (error) { alert('fetch failed n' + error.valueOf().toString()); }, 2000);
    }


 < /script>

<style type="text/css">
.sys-template { display:block; visibility:visible; }
</style>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <cc1:ToolkitScriptManager ID="ToolkitScriptManager1" ScriptMode = "Release" runat="server">
    <Services>
        <asp:ServiceReference Path="~/Services/VesselData.svc" />
    </Services>
    </cc1:ToolkitScriptManager>



< div id = "view">
    < ul id="template" 
        class="sys-template" sys:attach="dataview"
        dataview:autofetch="true"
        dataview:dataprovider="dataContext"
        dataview:fetchoperation="GetVesselData">
        < li>
               < h3>{{ VesselName }}</h3>
              < div>
                {{ VesselID }} <br />
                {{ CompanyID }} <br />
                {{ PublishQuestionnaire88 }} <br />
              < /div>
        </li>
    </ul>   
</div >
<input type="button"
       value="Perform binding"
       onclick="bind()" />
    
已邀请:
我遇到了同样的问题但是我正在使用来自CDN的Ajax脚本文件,直到我意识到Sys.registerComponent是在oda.org上的sdk上发布的MicrosoftAjax.debug.js上定义的。如果你使用缩小版本的MicrosoftAjax.js,它就会破坏
if (serviceUri) {
        this.set_path(serviceUri);
    }
并且没有定义set_path,这并不奇怪。 最后,我不得不使用MicrosoftAjax,MicrosoftAjaxDataContext,MicrosoftAjaxOpenData和MicrosoftAjaxTemplates的调试版本,并手动压缩文件以便发布。 我希望有人找出这个错误并修复相应的文件并将新版本上传到cdn。     

要回复问题请先登录注册