AboutAtlasThere are already many introductionsArticleI don't talk nonsense. For myself, learning a new thing is always used to starting with a simple example,AtlasThis article will take a very simple example.AtlasTrip, example in this articleProgramFromAtlasHome.
1. Create"Atlas"Application
After installationAtlasThenVisual StudioIn the project template ofAtlas"Web Site, Such. CreateAtlasSelect the application. In this wayBinThere will beMicrosoft. Web. Atlas. dll.
2. Create a simpleWeb Service
Now you need to create a simpleWeb ServiceFor"Atlas"Client script call,WebService. asmxPartial implementationCodeAs follows:
[Webmethod]
Public String Helloworld (string query)
{
String Inputstring = Server. htmlencode (query );
If ( ! String. isnullorempty (inputstring ))
{
ReturnString. Format ("Hello, You queried for {0}."
+ "Current Time is {1}", Inputstring, datetime. Now );
}
Else
{
Return "The query string was null or empty";
}
}
3. AddASP. NETPage
CreateASP. NETPage and add the client script to callWeb Service. OpenDefault. aspxThe following code is displayed:
< Atlas: scriptmanager Runat = "Server" ID = "Scriptmanager" >
</ Atlas: scriptmanager >
Scriptmanager YesAtlasAn important control used to process allAtlasComponent and partial page updates to generate related client scripts.ScriptmanagerFurther analysis will be made later. InScriptmanagerIntermediate IntroductionWeb ServicePath: < Atlas: scriptmanager Runat = "Server" ID = "Scriptmanager" >
< Services >
< Atlas: servicereference Path = "WebService. asmx" />
</ Services >
</ Atlas: scriptmanager >
Then write the client script and callWeb Service:
< Script Type = "Text/JavaScript" Language = "JavaScript" >
Function Dosearch ()
{
VaRSrchelem=Document. getelementbyid ("Searchkey");
WebService. helloworld (srchelem. Value, onrequestcomplete );
}
Function Onrequestcomplete (result)
{
VaRRsltelem=Document. getelementbyid ("Results");
Rsltelem. innerhtml=Result;
}
</ Script >
WhereDosearch ()Call MethodWeb ServiceRemote method,Onrequestcomplete ()When the asynchronous call is completed, the result is displayed in<Span>. CompleteDefault. aspxThe page code is as follows:
< Html Xmlns = "Http://www.w3.org/1999/xhtml" >
< Head ID = "Head1" Runat = "Server" >
< Title > Atlas script Walkthrough </ Title >
< Atlas: scriptmanager Runat = "Server" ID = "Scriptmanager" >
< Services >
< Atlas: servicereference Path = "WebService. asmx" />
</ Services >
</ Atlas: scriptmanager >
< Style Type = "Text/CSS" >
Body {} {Font:11pt trebuchet MS;
Font-color:#000000;
Padding-top:72px;
Text-align:Center}
. Text {} {Font:8pt trebuchet MS}
</ Style >
</ Head >
< Body >
< Form ID = "Form1" Runat = "Server" >
< Div >
Search
< Input ID = "Searchkey" Type = "Text" />
< Input ID = "Searchbutton" Type = "Button" Value = "Search" Onclick = "Dosearch ()" />
</ Div >
< Script Type = "Text/JavaScript" Language = "JavaScript" >
Function Dosearch ()
{
VaRSrchelem=Document. getelementbyid ("Searchkey");
WebService. helloworld (srchelem. Value, onrequestcomplete );
}
Function Onrequestcomplete (result)
{
VaRRsltelem=Document. getelementbyid ("Results");
Rsltelem. innerhtml=Result;
}
</ Script >
</ Form >
< HR Style = "Width: 300px" />
< Div >
< Span ID = "Results" > </ Span >
</ Div >
</ Body >
</ Html >
After running:
So far, a simpleAtlasThe application is complete. In subsequent articles, I will learn by myselfAtlasSome things in the process are recorded and shared with you.
Download the complete example