Learning Atlas with terrylee (1): Hello, Atlas

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.