Monday, December 1, 2008

'Sys' is Undefined. Javascript error when you use AJAX extension

You probably will notice a scripting error when using ASP.Net AJAX Extension in your web pages.

Error: 'Sys' is undefined.

It is due to the ajax extension is not properly registered and configured in your web.config.

Solution:

There are a few things that you need to have in your web config.

1.) Make sure you have add below line to your assembly under <compilation><assemblies>

<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />



2.) Add following lines under <system.web>



<httpHandlers>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>



3.) Add following line under <system.web><httpModules>



<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>



Cheers. This has solve my problem. I hope it does the same to you.



Some updates from Scott.



http://weblogs.asp.net/scottgu/archive/2006/10/29/tip_2f00_trick_3a00_-handling-errors-with-the-updatepanel-control-using-asp.net-ajax.aspx

No comments: