views:

509

answers:

1

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?

+2  A: 

Hi Herb

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

Matt Goddard
Thanks - actually, since I got no responses here I ended up using a variant of John Resig's micro-templating approach instead of jstemplates: http://ejohn.org/blog/javascript-micro-templating/
Herb Caudill
Until you mentioned it i'd never heard of javascript templating. I'm quite impressed so thanks for asking the question.
Matt Goddard