Author: dflying Chen (http://dflying.cnblogs.com /)
Most of the time, we need to call someWeb ServiceFor exampleAtlas listviewWill be immediately loadedGet the initial filling data. Although this can be usedAtlasOfInitialdataControls are completed, but for some other requirements, such as executingAtlasScript (whereAtlasPairJavascript), We still need a page loading event to trigger these operations.
Many of my friends use the following two methods:
- Directly on the pageScriptThe script to be executed.
- InOnload JavascriptEvent processing method.
These are incorrect methods, and errors may occur, for a simple reason:AtlasClient implementation is alsoJavascriptThe statement of the preceding two methods isAtlasClient implementation runs before initialization, which naturally leads to errors.
AtlasFully aware of this demand and providesFrameworkInternalOnloadEvent.Atlas frameworkTriggered after initialization. To capture this event, you needAtlas XML scriptStatement:
< Page Xmlns: script = "Http://schemas.microsoft.com/xml-script/2005" >
< Components >
< Application ID = "Application" Load = "Onapplicationload" />
</ Components >
</ Page >
WhereApplicationAs the currently runningAtlasProgramProvidesLoadEvent, so that we canAtlas frameworkAfter initialization, execute ourCode.
The following is an example,Web ServiceThe following is a simple addition of two numbers:
[Webmethod]
Public Int Addint ( Int Int1, Int Int2)
{
ReturnInt1+Int2;
}
ThenAspxAddScriptmanagerAndWeb ServiceReference:
< Atlas: scriptmanager ID = "Scriptmanager" Runat = "Server" Enablescriptcomponents = "True" >
< Services >
< Atlas: servicereference Path = "Simplewebservice. asmx" />
</ Services >
</ Atlas: scriptmanager >
Add two moreInputIt is used to provide two addition numbers:
< Input ID = "Value1" Type = "Text" Value = "1" />
< Input ID = "Value2" Type = "Text" Value = "2" />
Add captureAtlas framework LoadEventXML scriptDefinition:
< Script Type = "Text/XML-script" >
< Page Xmlns: script = "Http://schemas.microsoft.com/xml-script/2005" >
< Components >
< Application ID = "Application" Load = "Onapplicationload" />
</ Components >
</ Page >
</ Script >
The following are the event processing functions and their correspondingCallback, We can see three types of applicationsAtlas frameworkProvided extensions:
- $ ()Method, equivalentDocument. getelementbyid ()
- SYS. UI. textboxClass, encapsulatedHtmlOfInputElement
- PairWeb ServiceCalledMashup
Function Onapplicationload ()
{
VaR Value1 = New SYS. UI. Textbox ($ ('value1 '));
VaR Value2 = New SYS. UI. Textbox ($ ('value2 '));
Dflying. simplewebservice. addint (
Value1.get _ text (),
Value2.get _ text (),
Oncomplete
);
Return False ;
}
Function Oncomplete (result)
{
Alert (result );
}
Running result, no problem:
TheSource codeDownload here: http://files.cnblogs.com/dflying/ApplicationLoadEventDemo.zip