AutoComplete
?????????? AutoComplete :显示文本框扩展功能,当在文本框输出内容时会随机出现一此字符,如IE中的输出网址,如果你在以前输入过这个网址,只要在输入前几个字母就好了,但以代码需要再修改才能实现
?
using System; using System.Web; using System.Collections.Generic;//新介入 using System.Web.Services; using System.Web.Services.Protocols;
?
?
/// <summary> /// WebService 的摘要说明 /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.Web.Script.Services.ScriptService]//调用WebSever方法签名 public class WebService : System.Web.Services.WebService {
?
??? public WebService () {
?
??????? //如果使用设计的组件,请取消注释以下行 ??????? //InitializeComponent(); ??? }
?
??? [WebMethod] ??? //prefixText:在文本框中写入的字符,count:写入之后随机产生多少条信息 ??? public string[] GetCompletionList(string prefixText,int count) ??? { ??????? if (count == 0) ??????? { ??????????? count = 10; ??????? }
?
??????? Random random = new Random(); ??????? List<string> items = new List<string>(count);//列表存放多少条信息 ??????? for (int i = 0; i < count; i++) ??????? { ?????????? char c1= (char) random.Next(65,90);//小写字母 ??????????? char c2 =(char) random.Next(97,122);//大写字母 ??????????? char c3 = (char)random.Next(48,57);//数字 ??????????? char c4=(char) random.Next(33,43); ??????????? items.Add(prefixText+c1+c2+c3+c4); ??????????? }
?
???? ??????return items.ToArray(); ??? }
?
} 1.??? 在TextBox中属性中的ace/serverPath加入WebService.asmx,ServerMethod中介入GetCompletionList(),CompletionInterval 100影响时间为0.1秒,MinimumPrefixLength介入1,最少介入的字符数 2.??? AutoCompleteExtender绑定MyAuto ?(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |