ajaxToolKit There is a autoCompleteExtender extension of the TextBox, there can be realized in the drop-down box prompts text input box. Good results. Use AjaxToolKit need to install asp.net ajax extensions of tools: an official document , and then reference the DLL. Reception follows:
< asp:AutoCompleteExtender ID ="AutoCompleteExtender1" runat ="server"
TargetControlID ="txtID"
ServicePath ="autoCompExtenderServer.asmx"
ServiceMethod ="GetData"
CompletionSetCount ="10"
FirstRowSelected ="true"
MinimumPrefixLength ="1"
>
</ asp:AutoCompleteExtender >
Which represents the bound TextBox TargetControlID
ServicePath: Service path
ServiceMethod: automatic prompt method name
CompletionSetCount: the number of display
FirstRowSelected: whether to automatically select the first line prompt
MinimumprefixLength: Enter the number of words began when prompted;
autoCompExtenderServer.asmx background code
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Runtime.Serialization;
using System.Web.Script.Serialization;
namespace auotoCompleteText
{
/// <summary>
/// autoCompExtenderServer 的摘要说明
/// </summary>
[WebService(Namespace = " http://tempuri.org/ " )]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem( false )]
// To allow the use of ASP.NET AJAX Web service from calling this script, uncomment the downside. [System.Web.Script.Services.ScriptService] public class autoCompExtenderServer: the System.Web.Services.WebService { [the WebMethod] public String [] the GetData ( String prefixText, int COUNT) { String [] Data = new new String [ 10000 ]; for ( int I = 0 ; I < data.length; I ++ ) Data [I] = i.ToString ( " 0000
" );
return data.Where(p => p.IndexOf(prefixText) >= 0 ).Take(count).ToArray();
}
}
}
Note that two parameters: prefixText, count not change.
Reference: http: //moosdau.blog.163.com/blog/static/43711282008824113942459/
Reproduced in: https: //www.cnblogs.com/xinjian/archive/2010/11/24/1886283.html