[out of date post... this deals with MS Atlas CTP... which has been change drastically and is now MS Ajax Extensions]
I was browsing the Atlas source code this evening and encountered a gem that I don’t want to forget.
When you are calling a PageMethod (method in the ASPX codebehind) from JavaScript(documented in numerous places elsewhere in my blog), here are the additional arguments that appear after the actual method’s arguments – onMethodComplete, onMethodTimeout, onMethodError, onMethodAborted, userContext, timeoutInterval, priority, useGetMethod.
So if you have my infamous “add” method in a codebehind page that takes 2 integers (arg1 and arg2) as arguments then the javascript add PageMethod will accept the following arguments (in this order): arg1, arg2, onMethodComplete, onMethodTimeout, onMethodError, onMethodAborted, userContext, timeoutInterval, priority, useGetMethod.
BTW, onMethodComplete, onMethodTimeout, onMethodError, onMethodAborted are all callback functions. userContext can be very userful as it lets you specify a parameter that will arrive back to the caller that you can use to figure out what was going on in the code when this was called. I was studying one of the behaviors (you guess which one) which simply put a copy of the current object and a string in an array and called that context. On complete it was able to call a method on the right object (you lose context in these types of callbacks… the same is true for WebServices).
Technorati Tags: Atlas, Ajax, ASP.Net