Ajax.NET Professional, enums and global onError/onLoading events

Michael Schwarz on Tuesday, April 4, 2006

The version [1] has fixed the missing enum support, now. To register an enum for client-side JavaScript code you have to add following code (the old AjaxEnum attribute is not needed):


void Page_Load(object sender, EventArgs e) { AjaxPro.Utility.RegisterEnumForAjax(typeof(MyNameSpace.MyEnum)); } With this code you can check your result on the client-side JavaScript like this:


script type="text/javascript"> function mycallback(res) { if(res.value == MyNameSpace.MyEnum.Value1) { alert("Is value1!"); } } </script> A new web.config tag will return an exception with more information like Stack, TargetSite and Source. See the following example web.config:


xml version="1.0"?> <configuration> <configSections> <sectionGroup name="ajaxNet"> <section name="ajaxSettings" type="AjaxPro.AjaxSettingsSectionHandler,AjaxPro" requirePermission="false" restartOnExternalChanges="true" /> </sectionGroup> </configSections> <ajaxNet> <ajaxSettings> <urlNamespaceMappings> <add type="AJAXDemo.WebForm1,AJAXDemo" path="sample" /> </urlNamespaceMappings> <jsonConverters> <add type="AJAXDemo.Examples.Classes.PersonConverter,AJAXDemo"/> </jsonConverters> <debug enabled="true" /> <scriptReplacements> <file name="core" path="~/ajaxpro/core.ashx" /> <file name="prototype" path="~/ajaxpro/prototype.ashx" /> <file name="converter" path="~/ajaxpro/converter.ashx" /> </scriptReplacements> <!-- <encryption cryptType="" keyType="" /> --> <token enabled="true" sitePassword="password" /> </ajaxSettings> </ajaxNet> <system.web> <httpHandlers> <add verb="" path="ajaxpro/.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro"/> </httpHandlers> </system.web> </configuration> Note: if you are using ASP.NET 2.0 your have to replace all assembly names with AjaxPro.2 (line 6 and 41).

The next new thing is that you can add global event handlers for onLoading, onError and onTimeout. In earlier version you had to add these handlers to any class JavaScript wrapper. If you want to add an global onLoading event you can now use this JavaScript code (the same for onError and onTimeout):


script type="text/javascript"> AjaxPro.onLoading = function(b) { if(b) { window.status = "Loading..."; } else { window.status = ""; } } </script> Please download the latest release from http://www.ajaxpro.info/ [2], feedback and support available at the Google group for Ajax.NET Professional [3].