1.安装
下载地址:http://go.microsoft.com/fwlink/?LinkId=52384
参考:http://atlas.asp.net/docs/Overview/Install.aspx
下面两个文件新建时选择“将代码放在单独的文件中”
2.新建WebService
//HelloWorldService.asmx
<%@ WebService Language="C#" Class="Samples.AspNet.HelloWorldService" %>
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
namespace Samples.AspNet {
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class HelloWorldService : System.Web.Services.WebService {
[WebMethod]
public string HelloWorld(String query)
{
string inputString = Server.HtmlEncode(query);
if(!String.IsNullOrEmpty(inputString))
{
return String.Format("Hello, you queried for {0}. The "
+ "current time is {1}", inputString, DateTime.Now);
}
else
{
return "The query string was null or empty";
}
}
}
}
3.新建aspx
//default.aspx
<%@ Page Language="C#" Title="Atlas Script Walkthrough" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<atlas:ScriptManager runat="server" ID="scriptManager">
<services>
<atlas:servicereference path="~/HelloWorldService.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 runat="server">
<div>
Search for
<input id="SearchKey" type="text" />
<input id="SearchButton" type="button"
value="Search"
οnclick="DoSearch()" />
</div>
</form>
<hr style="width: 300px" />
<div>
<span id="Results"></span>
</div>
<script type="text/javascript">
function DoSearch()
{
var SrchElem = document.getElementById("SearchKey");
Samples.AspNet.HelloWorldService.HelloWorld(SrchElem.value,
OnRequestComplete);
}
function OnRequestComplete(result)
{
var RsltElem = document.getElementById("Results");
RsltElem.innerHTML = result;
}
</script>
</body>
</html>
4.原文:http://atlas.asp.net/docs/Walkthroughs/GetStarted/Basic.aspx