Calling into the Atlas API OnLoad

Posted Thursday, July 27, 2006 1:06 PM by C-Dog's .NET Tip of the Day

Atlas makes it really easy to make client side to web services and what not. Recently I discovered a scenario where I want to call directly to an Atlas web service on page load through JavaScript code. The problem with this is that no call to the Atlas API can be made until Window.OnLoad executes. Therefore if you have any inline javascript in the page calling the Atlas API, you will end up with an object not found error.

Luckily Atlas has a method that you can pass a delegate to for this situation. By calling Sys.Application.load.add, you can have any function of your own access the API when the page loads. The syntax would look something like the code below.

function MyFunction()
{
    // do something like call atlas web service
}

// pass a delegate to atlas's method to add onload
Sys.Application.load.add(MyFunction);

Read the complete post at http://www.dotnettipoftheday.com/blog.aspx?id=290