Tuesday, February 19, 2013

ASP.NET MVC AJAX Sys is undefined error (ASP.NET MVC 2.0 Remote Validation)

Referencing a remote validation can be a pain in the arse since several javascript errors will pop up such as stated in the title. So, in order to remove those unwanted script errors in ASP.NET MVC 2.0, use the solution below.
 <script src="<%= Url.Content("~/Scripts/MicrosoftAjax.debug.js") %>" type="text/javascript"></script>    
 <script src="<%= Url.Content("~/Scripts/MicrosoftMvcValidation.debug.js") %>" type="text/javascript"></script>  
 <script src="../../Scripts/RemoteValidationScript.js" type="text/javascript"></script>  

Note: RemoteValidationScript.js is an external Validation javascript file. The referencing of scripts should be in order to avoid null or property not found javascript exceptions(RemoteValidationScript should be referenced last). You may also use (../../Scripts/MicrosoftAjax.debug.js) for long method.

Reference: Sys is undefined error

Cheers!

Greg

0 comments:

Post a Comment