Callbacks in Asp.net Ajax
Callbacks provide an ability to call a function passing in additional parameters that your function would need. In the past to achieve this objective, I have created global variables that can be referenced from any where in your code. . Instead using callbacks, you can pass in a context that has the information your function would need. In the example below, I am passing an array of numbers to a callback function which simply writes the array to a label. Here is the markup
In the above code, the second parameter to createCallBack method is the context that you want the actual function to receive. The context could be anything which in my case is an array of integers. In the PrintArray method the second parameter is the context that you have passed earlier. Using that context (array of ints), I am simply append the integer to a label on the screen.