Having tested a simple atlas web method call from the client which is fired by calling a javascript function on a button client side click event -it works perfectly.
The problem is I need this function called when the page loads, however whenever calling this function from either the body onload client side event or by using the RegisterStratupScript on the server side page load method, I get a javascript error refering to the web service class name as being undefined.
In theory this should work, Am I missing something regarding my understanding of the atlas lifecycle perhaps?
Please help!
Thanks
Dynamic script references (included in the References section of the ScriptManager) are not available until after page loading. To use these, you need to hook the Load event of the Application object. Declaratively, you can do this with:
<application>
<load>
<invokeMethod method="MyMethodName" />
</load>
</application>
Alternatively, you can statically include the service with a <script> tag.
A simpler syntax to do this is to have:
<application load="OnApplicationLoad" />
This goes into your <components>. So you would have something like this:
<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<references>
</references>
<components>
<application load="OnApplicationLoad" />
</components>
</page>
</script>
David
BTW, I should mention that there is yet an easier way: just name your method pageLoad and it will be automatically called without having to be registered. See theAtlas docs for some examples.
David
No comments:
Post a Comment