简体   繁体   中英

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. The problem is not jstemplate.js but util.js, which it needs as a support file.

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 :

 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.

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? Or should I just look into alternative client-side templating engines?

We had a similar problem with ASP.net AJAX and jQuery. The problem was down to the $ namespace, so we had to revert back to using the jQuery namespace.

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.

HTH

Matt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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