CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Jay Kimble -- The Dev Theologian

Philosophizing about the .Net religion

Atlas PageMethods -- expected arguments

[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: , ,


Published Jul 06 2006, 12:11 AM by Jay Kimble
Filed under: , ,

Check out Devlicio.us!

Our Sponsors

This Blog

Syndication

News

CodeBetter.Com Home
Current Threat level
Terror Alert Level