‘Sys’ is undefined or ASP.NET Ajax client-side framework failed to load in a ASP .NET 4.0 website

I was getting the the error [‘Sys’ is undefined] and [ASP.NET Ajax client-side framework failed to load] in an ASP .NET 4.0 website. After reading and following the post [http://weblogs.asp.net/chrisri/archive/2007/02/02/demystifying-sys-is-undefined.aspx] I found my solution.

De ScriptResource.axd [long url] was throwing a 404 server error. This was caused by the fact that the website had an application pool set to .NET 4.0 but the [Handler Mappings] (see Screen dump 001) for the *.axd files where not registered. Even after executing the [aspnet_regiis –i –enable] the [Handler Mappings] where not registered. After re-creating the site, the error was resolved. The screen dump 002 shows the correct handler mappings.

 

Screen dump 001

image

 

Screen dump 002

image

Do a postback from javascript with ASP .NET AJAX

If you want to do a postback from javascript with ASP .NET AJAX and the aspx page contains a

<form id="mainForm" runat="server">

, you can create and use the javascript function to do a postback from javascript:



function
DoPostBack() {

    var form = document.getElementById(‘mainForm’);

    form.submit();

}