Atlas 学习笔记: ajax 改进 by Atlas
来源:互联网 发布:北京软件游戏培训班 编辑:程序博客网 时间:2024/05/16 17:09
废话不多说,今天试试atlas
1. 加入atlas 的 scriptManager 因为是后台直接调webservice 所以加上webservice的地址
<atlas:ScriptManager ID="scriptManager" runat="server">
<Services>
<atlas:ServiceReference Path="WebService.asmx" />
</Services>
</atlas:ScriptManager>
<Services>
<atlas:ServiceReference Path="WebService.asmx" />
</Services>
</atlas:ScriptManager>
2. OK 在来一个text 注意在后面 spanid 要加一个名字 这个名字要和下面对应起来
<input id="Text1" type="text" /><span id="Text1__autocomplete"></span>
3. 这段代码大家看看 指定 text1 要完成的行为 behaviors 里面指定了autoComplete 指定了方法serviceMethod="GetCompletionList" minimumPrefixLength ="1" 指定你输入多少个字符就开始触发这个auto事件最后 completionList ="Text1__autocomplete" 这个名字和第二步的名字 要统一
<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<label id="Text1" targetElement="Text1">
<behaviors>
<autoComplete serviceURL="WebService.asmx" serviceMethod="GetCompletionList" minimumPrefixLength="1" completionList="Text1__autocomplete" />
</behaviors>
</label>
</components>
<references>
</references>
</page>
</script>
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<label id="Text1" targetElement="Text1">
<behaviors>
<autoComplete serviceURL="WebService.asmx" serviceMethod="GetCompletionList" minimumPrefixLength="1" completionList="Text1__autocomplete" />
</behaviors>
</label>
</components>
<references>
</references>
</page>
</script>
4 下面来写webservice时候实现 的代码 基本上就是一个查询 注意返回值的类型
[WebMethod]
public string[] GetCompletionList(string prefixText)
{
string temp = "";
List<string> suggestions = new List<string>();
if (prefixText != "")
{
string mySelectQuery = "SELECT ContactName FROM Customers where ContactName like '" + prefixText + "%'";
SqlConnection myConnection = new SqlConnection(@"server=ZTE-WUANCHENG/wuancheng_zte;database=Northwind;User ID=sa;password=;Persist Security Info=true;");
SqlCommand myCommand = new SqlCommand(mySelectQuery, myConnection);
myConnection.Open();
SqlDataReader myReader = myCommand.ExecuteReader();
try
{
while (myReader.Read())
{
suggestions.Add(myReader.GetString(0));
temp = temp + myReader.GetString(0) + ", ";
}
}
finally
{
// always call Close when done reading.
myReader.Close();
// always call Close when done reading.
myConnection.Close();
}
}
return suggestions.ToArray();
}
public string[] GetCompletionList(string prefixText)
{
string temp = "";
List<string> suggestions = new List<string>();
if (prefixText != "")
{
string mySelectQuery = "SELECT ContactName FROM Customers where ContactName like '" + prefixText + "%'";
SqlConnection myConnection = new SqlConnection(@"server=ZTE-WUANCHENG/wuancheng_zte;database=Northwind;User ID=sa;password=;Persist Security Info=true;");
SqlCommand myCommand = new SqlCommand(mySelectQuery, myConnection);
myConnection.Open();
SqlDataReader myReader = myCommand.ExecuteReader();
try
{
while (myReader.Read())
{
suggestions.Add(myReader.GetString(0));
temp = temp + myReader.GetString(0) + ", ";
}
}
finally
{
// always call Close when done reading.
myReader.Close();
// always call Close when done reading.
myConnection.Close();
}
}
return suggestions.ToArray();
}
5 . ok 看看效果
http://www.cnblogs.com/arthur_wuancheng/archive/2006/03/16/351319.html
- Atlas 学习笔记: ajax 改进 by Atlas
- Ajax与Atlas开发笔记
- ASP.NET AJAX (Atlas)学习
- ASP.NET AJAX (Atlas)学习
- Atlas学习手记(Ajax.net)
- ajax与asp.net2.0学习笔记(2)-atlas架构
- Atlas学习笔记(一)
- Atlas学习笔记2:UpdateMode
- atlas学习
- Atlas
- atlas
- Atlas
- atlas
- Atlas
- AJAX学习之Atlas框架之概述
- ajax&atlas集合
- xml, AJAX 与ATLAS
- Atlas:微软的Ajax
- 如何在DataGrid中进行添加、删除和修改操作
- 十年MFC经历认识的Microsoft技术
- Ajax缘何流行—来看看大象本身
- 在水晶报表中动态的添加自己所需要的的字段
- C#.NET中的类型转换
- Atlas 学习笔记: ajax 改进 by Atlas
- 对象序列化笔记
- Ajax程序设计入门
- 消除左递归文法
- datagrid控件中添加checkbox控件列
- 【AjaxPro实现机制浅析一】AjaxPro内部为我们做什么工作?
- 转帖:『IT视界』 [互联网]中国电信试点宽带按流量计费 变相封杀BT下载!
- 软件开发技术常用术语英中对照
- [大话IT]网易股价逼近100美元 丁磊个人财富狂飙