Atlas自动完成
src:
webservice:
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
<head>
4
<title>Simple</title>
5
<link type="text/css" rel="stylesheet" href="simple.css" />
6![](/Images/OutliningIndicators/None.gif)
7
<atlas:ScriptManager ID="scriptManager" runat="server">
8
<Services>
9
<atlas:ServiceReference Path="AnimalService.asmx" />
10
</Services>
11
</atlas:ScriptManager>
12![](/Images/OutliningIndicators/None.gif)
13
</head>
14
<body>
15
<form id="form1" name="form1" runat="server">
16
<div id="logo">
17
<h1>
18
Simple</h1>
19
</div>
20
<div id="header">
21
Search:
22
<input id="Text1" type="text" /><span id="Text1__autocomplete"></span>
23
<input id="Button1" type="button" value="Search" onclick="Button1_onclick();" />
24
<br />
25
(enter Cat, Cow, Dog or Parrot)
26
</div>
27
<!-- Main Content -->
28
<div id="content">
29
<div class="left">
30
<div id="searchResults">
31
</div>
32
<div style="display: none;">
33
<div id="searchResults_layoutTemplate">
34
<ul id="searchResults_itemTemplateParent">
35
<li id="searchResults_itemTemplate">
36
<span id="searchResults_Name"></span>
37
<span id="searchResults_Category"></span>
38
<span id="searchResults_Color"></span></li>
39
</ul>
40
</div>
41
</div>
42
</div>
43
</div>
44
</form>
45![](/Images/OutliningIndicators/None.gif)
46
<script type="text/xml-script">
47
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
48
<components>
49
<textBox id="Text1">
50
<behaviors>
51
<autoComplete serviceURL="AnimalService.asmx" serviceMethod="GetCompletionList" minimumPrefixLength="1" completionList="Text1__autocomplete" />
52
</behaviors>
53
</textBox>
54
<listView id="searchResults" cssClass="listView" itemTemplateParentElementId="searchResults_itemTemplateParent" alternatingItemCssClass="alternatingItem" itemCssClass="item">
55
<layoutTemplate>
56
<template layoutElement="searchResults_layoutTemplate" />
57
</layoutTemplate>
58
<itemTemplate>
59
<template layoutElement="searchResults_itemTemplate">
60
<label id="searchResults_Name">
61
<bindings>
62
<binding dataPath="Name" property="text" />
63
</bindings>
64
</label>
65
<label id="searchResults_Category">
66
<bindings>
67
<binding dataPath="Category" property="text" />
68
</bindings>
69
</label>
70
<label cssClass="bar" id="searchResults_Color">
71
<bindings>
72
<binding dataPath="Color" property="text" />
73
</bindings>
74
</label>
75
</template>
76
</itemTemplate>
77
</listView>
78
</components>
79
<references>
80
</references>
81
</page>
82
</script>
83![](/Images/OutliningIndicators/None.gif)
84
<script language="javascript" type="text/javascript">
85
function Button1_onclick() {
86
Quickstart.Samples.Data.AnimalService.GetAnimals(document.getElementById("Text1").value, onSearchComplete);
87
}
88
89
function onSearchComplete(results) {
90
var searchResults = document.getElementById("searchResults");
91
searchResults.control.set_data(results);
92
}
93
</script>
94![](/Images/OutliningIndicators/None.gif)
95
</body>
96
</html>
97![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
8
![](/Images/OutliningIndicators/None.gif)
9
![](/Images/OutliningIndicators/None.gif)
10
![](/Images/OutliningIndicators/None.gif)
11
![](/Images/OutliningIndicators/None.gif)
12
![](/Images/OutliningIndicators/None.gif)
13
![](/Images/OutliningIndicators/None.gif)
14
![](/Images/OutliningIndicators/None.gif)
15
![](/Images/OutliningIndicators/None.gif)
16
![](/Images/OutliningIndicators/None.gif)
17
![](/Images/OutliningIndicators/None.gif)
18
![](/Images/OutliningIndicators/None.gif)
19
![](/Images/OutliningIndicators/None.gif)
20
![](/Images/OutliningIndicators/None.gif)
21
![](/Images/OutliningIndicators/None.gif)
22
![](/Images/OutliningIndicators/None.gif)
23
![](/Images/OutliningIndicators/None.gif)
24
![](/Images/OutliningIndicators/None.gif)
25
![](/Images/OutliningIndicators/None.gif)
26
![](/Images/OutliningIndicators/None.gif)
27
![](/Images/OutliningIndicators/None.gif)
28
![](/Images/OutliningIndicators/None.gif)
29
![](/Images/OutliningIndicators/None.gif)
30
![](/Images/OutliningIndicators/None.gif)
31
![](/Images/OutliningIndicators/None.gif)
32
![](/Images/OutliningIndicators/None.gif)
33
![](/Images/OutliningIndicators/None.gif)
34
![](/Images/OutliningIndicators/None.gif)
35
![](/Images/OutliningIndicators/None.gif)
36
![](/Images/OutliningIndicators/None.gif)
37
![](/Images/OutliningIndicators/None.gif)
38
![](/Images/OutliningIndicators/None.gif)
39
![](/Images/OutliningIndicators/None.gif)
40
![](/Images/OutliningIndicators/None.gif)
41
![](/Images/OutliningIndicators/None.gif)
42
![](/Images/OutliningIndicators/None.gif)
43
![](/Images/OutliningIndicators/None.gif)
44
![](/Images/OutliningIndicators/None.gif)
45
![](/Images/OutliningIndicators/None.gif)
46
![](/Images/OutliningIndicators/None.gif)
47
![](/Images/OutliningIndicators/None.gif)
48
![](/Images/OutliningIndicators/None.gif)
49
![](/Images/OutliningIndicators/None.gif)
50
![](/Images/OutliningIndicators/None.gif)
51
![](/Images/OutliningIndicators/None.gif)
52
![](/Images/OutliningIndicators/None.gif)
53
![](/Images/OutliningIndicators/None.gif)
54
![](/Images/OutliningIndicators/None.gif)
55
![](/Images/OutliningIndicators/None.gif)
56
![](/Images/OutliningIndicators/None.gif)
57
![](/Images/OutliningIndicators/None.gif)
58
![](/Images/OutliningIndicators/None.gif)
59
![](/Images/OutliningIndicators/None.gif)
60
![](/Images/OutliningIndicators/None.gif)
61
![](/Images/OutliningIndicators/None.gif)
62
![](/Images/OutliningIndicators/None.gif)
63
![](/Images/OutliningIndicators/None.gif)
64
![](/Images/OutliningIndicators/None.gif)
65
![](/Images/OutliningIndicators/None.gif)
66
![](/Images/OutliningIndicators/None.gif)
67
![](/Images/OutliningIndicators/None.gif)
68
![](/Images/OutliningIndicators/None.gif)
69
![](/Images/OutliningIndicators/None.gif)
70
![](/Images/OutliningIndicators/None.gif)
71
![](/Images/OutliningIndicators/None.gif)
72
![](/Images/OutliningIndicators/None.gif)
73
![](/Images/OutliningIndicators/None.gif)
74
![](/Images/OutliningIndicators/None.gif)
75
![](/Images/OutliningIndicators/None.gif)
76
![](/Images/OutliningIndicators/None.gif)
77
![](/Images/OutliningIndicators/None.gif)
78
![](/Images/OutliningIndicators/None.gif)
79
![](/Images/OutliningIndicators/None.gif)
80
![](/Images/OutliningIndicators/None.gif)
81
![](/Images/OutliningIndicators/None.gif)
82
![](/Images/OutliningIndicators/None.gif)
83
![](/Images/OutliningIndicators/None.gif)
84
![](/Images/OutliningIndicators/None.gif)
85
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
86
![](/Images/OutliningIndicators/InBlock.gif)
87
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
88
![](/Images/OutliningIndicators/None.gif)
89
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
90
![](/Images/OutliningIndicators/InBlock.gif)
91
![](/Images/OutliningIndicators/InBlock.gif)
92
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
93
![](/Images/OutliningIndicators/None.gif)
94
![](/Images/OutliningIndicators/None.gif)
95
![](/Images/OutliningIndicators/None.gif)
96
![](/Images/OutliningIndicators/None.gif)
97
![](/Images/OutliningIndicators/None.gif)
webservice:
1
<%@ WebService Language="C#" Class="Quickstart.Samples.Data.AnimalService" %>
2![](/Images/OutliningIndicators/None.gif)
3
using System;
4
using System.Web;
5
using System.Collections;
6
using System.Collections.Generic;
7
using System.Web.Services;
8
using System.Web.Services.Protocols;
9![](/Images/OutliningIndicators/None.gif)
10
namespace Quickstart.Samples.Data
11
{
12
public class Animal
13
{
14
String _name;
15
String _category;
16
String _color;
17
18
public String Name
19
{
20
get { return _name; }
21
set { _name = value; }
22
}
23![](/Images/OutliningIndicators/InBlock.gif)
24
public String Category
25
{
26
get { return _category; }
27
set { _category = value; }
28
}
29
30
public String Color
31
{
32
get { return _color; }
33
set { _color = value; }
34
}
35![](/Images/OutliningIndicators/InBlock.gif)
36
public Animal(String name, String category, String color)
37
{
38
_name = name;
39
_category = category;
40
_color = color;
41
}
42
};
43
44
[WebService(Namespace = "http://tempuri.org/")]
45
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
46
public class AnimalService : System.Web.Services.WebService
47
{
48
[WebMethod]
49
public string[] GetCompletionList(string prefixText, int count)
50
{
51
prefixText = prefixText.ToLower();
52
string[] categories = {
53
"Cat",
54
"Dog",
55
"Cow",
56
"Parrot",
57
};
58
59
List<string> suggestions = new List<string>();
60
foreach (string category in categories)
61
{
62
if (category.ToLower().StartsWith(prefixText))
63
{
64
suggestions.Add(category);
65
}
66
}
67
return suggestions.ToArray();
68
}
69
70
[WebMethod]
71
public Animal[] GetAnimals(String searchText)
72
{
73
List<Animal> _data = GetAllAnimals();
74![](/Images/OutliningIndicators/InBlock.gif)
75
if (String.IsNullOrEmpty(searchText))
76
{
77
return _data.ToArray();
78
}
79![](/Images/OutliningIndicators/InBlock.gif)
80
List<Animal> _dataFiltered = new List<Animal>();
81
foreach (Animal animal in _data)
82
{
83
if (searchText.ToLower().CompareTo(animal.Category.ToLower()) == 0)
84
_dataFiltered.Add(animal);
85
}
86![](/Images/OutliningIndicators/InBlock.gif)
87
return _dataFiltered.ToArray();
88
}
89![](/Images/OutliningIndicators/InBlock.gif)
90
List<Animal> GetAllAnimals()
91
{
92
List<Animal> _data = new List<Animal>();
93![](/Images/OutliningIndicators/InBlock.gif)
94
_data.Add(new Animal("Felix", "Cat", "Grey"));
95
_data.Add(new Animal("Fido", "Dog", "Brown"));
96
_data.Add(new Animal("Rover", "Dog", "Brown"));
97
_data.Add(new Animal("Daisy", "Cow", "Black and White"));
98
_data.Add(new Animal("Polly", "Parrot", "Green"));
99![](/Images/OutliningIndicators/InBlock.gif)
100
return _data;
101
}
102
}
103
}
104
105![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
8
![](/Images/OutliningIndicators/None.gif)
9
![](/Images/OutliningIndicators/None.gif)
10
![](/Images/OutliningIndicators/None.gif)
11
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
12
![](/Images/OutliningIndicators/InBlock.gif)
13
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
14
![](/Images/OutliningIndicators/InBlock.gif)
15
![](/Images/OutliningIndicators/InBlock.gif)
16
![](/Images/OutliningIndicators/InBlock.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
20
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
21
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
22
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/InBlock.gif)
25
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
26
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
27
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
28
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
29
![](/Images/OutliningIndicators/InBlock.gif)
30
![](/Images/OutliningIndicators/InBlock.gif)
31
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
32
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
33
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
34
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
35
![](/Images/OutliningIndicators/InBlock.gif)
36
![](/Images/OutliningIndicators/InBlock.gif)
37
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
38
![](/Images/OutliningIndicators/InBlock.gif)
39
![](/Images/OutliningIndicators/InBlock.gif)
40
![](/Images/OutliningIndicators/InBlock.gif)
41
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
42
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
43
![](/Images/OutliningIndicators/InBlock.gif)
44
![](/Images/OutliningIndicators/InBlock.gif)
45
![](/Images/OutliningIndicators/InBlock.gif)
46
![](/Images/OutliningIndicators/InBlock.gif)
47
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
48
![](/Images/OutliningIndicators/InBlock.gif)
49
![](/Images/OutliningIndicators/InBlock.gif)
50
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
51
![](/Images/OutliningIndicators/InBlock.gif)
52
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
53
![](/Images/OutliningIndicators/InBlock.gif)
54
![](/Images/OutliningIndicators/InBlock.gif)
55
![](/Images/OutliningIndicators/InBlock.gif)
56
![](/Images/OutliningIndicators/InBlock.gif)
57
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
58
![](/Images/OutliningIndicators/InBlock.gif)
59
![](/Images/OutliningIndicators/InBlock.gif)
60
![](/Images/OutliningIndicators/InBlock.gif)
61
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
62
![](/Images/OutliningIndicators/InBlock.gif)
63
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
64
![](/Images/OutliningIndicators/InBlock.gif)
65
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
66
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
67
![](/Images/OutliningIndicators/InBlock.gif)
68
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
69
![](/Images/OutliningIndicators/InBlock.gif)
70
![](/Images/OutliningIndicators/InBlock.gif)
71
![](/Images/OutliningIndicators/InBlock.gif)
72
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
73
![](/Images/OutliningIndicators/InBlock.gif)
74
![](/Images/OutliningIndicators/InBlock.gif)
75
![](/Images/OutliningIndicators/InBlock.gif)
76
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
77
![](/Images/OutliningIndicators/InBlock.gif)
78
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
79
![](/Images/OutliningIndicators/InBlock.gif)
80
![](/Images/OutliningIndicators/InBlock.gif)
81
![](/Images/OutliningIndicators/InBlock.gif)
82
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
83
![](/Images/OutliningIndicators/InBlock.gif)
84
![](/Images/OutliningIndicators/InBlock.gif)
85
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
86
![](/Images/OutliningIndicators/InBlock.gif)
87
![](/Images/OutliningIndicators/InBlock.gif)
88
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
89
![](/Images/OutliningIndicators/InBlock.gif)
90
![](/Images/OutliningIndicators/InBlock.gif)
91
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
92
![](/Images/OutliningIndicators/InBlock.gif)
93
![](/Images/OutliningIndicators/InBlock.gif)
94
![](/Images/OutliningIndicators/InBlock.gif)
95
![](/Images/OutliningIndicators/InBlock.gif)
96
![](/Images/OutliningIndicators/InBlock.gif)
97
![](/Images/OutliningIndicators/InBlock.gif)
98
![](/Images/OutliningIndicators/InBlock.gif)
99
![](/Images/OutliningIndicators/InBlock.gif)
100
![](/Images/OutliningIndicators/InBlock.gif)
101
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
102
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
103
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
104
![](/Images/OutliningIndicators/None.gif)
105
![](/Images/OutliningIndicators/None.gif)