简体   繁体   English

Google util.js和ASP.NET AJAX之间有冲突吗?

[英]Conflict between Google util.js and ASP.NET AJAX?

I'm trying to use Google's jstemplate as a client-side templating engine on an ASP.NET page, and it seems to be conflicting with ASP.NET AJAX. 我正在尝试使用Google的jstemplate作为ASP.NET页上的客户端模板引擎,并且它似乎与ASP.NET AJAX冲突。 The problem is not jstemplate.js but util.js, which it needs as a support file. 问题不是jstemplate.js,而是util.js,它需要作为支持文件。

I've isolated the problem as follows:: 我将问题隔离如下:

<%@ Page Language="VB" %>
<body>
    <form id="form1" runat="server">
        <asp:scriptmanager id="ScriptManager" runat="server" enablepartialrendering="true">
            <scripts>
                <asp:scriptreference path="http://google-jstemplate.googlecode.com/svn/trunk/util.js" />
            </scripts>
        </asp:scriptmanager>
    </form>
</body>
</html>

When I run this I get this error 当我运行这个我得到这个错误

Microsoft JScript runtime error: 'type' is null or not an object`

on this line of MicrosoftAjax.js : 在此行MicrosoftAjax.js

 Sys.UI.DomEvent = function Sys$UI$DomEvent(eventObject) {
 ...
 var etype = this.type = e.type.toLowerCase();

Referencing the javascript in a normal <script> block (as opposed to inside the ScriptManager) has the same effect. 在普通的<script>块中(而不是在ScriptManager中)引用javascript具有相同的效果。

I haven't dug into it but I suspect there's just a namespace collision. 我没有深入研究它,但我怀疑只是名称空间冲突。 Has anyone successfully used Google's util.js file alongside ASP.NET ajax? 有没有人成功地将Google的util.js文件与ASP.NET ajax一起使用? Or should I just look into alternative client-side templating engines? 还是我应该研究其他客户端模板引擎?

We had a similar problem with ASP.net AJAX and jQuery. 我们在ASP.net AJAX和jQuery中也遇到了类似的问题。 The problem was down to the $ namespace, so we had to revert back to using the jQuery namespace. 问题归结于$名称空间,因此我们不得不恢复使用jQuery名称空间。

Your error sounds similar, so i would look to see if you have an alternative namespace for the google util.js or set one up for yourself. 您的错误听起来很类似,所以我想看看您是否有google util.js的替代名称空间,或者自己设置一个名称空间。

HTH HTH

Matt 马特

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM