テキストボックスのautoCompleteExtender拡張子がありajaxToolKit、ドロップダウンボックスで実現することができるテキスト入力ボックスを求めるメッセージが表示されます。良好な結果。:使用AjaxToolKitは、ツールのasp.netのAjaxの拡張機能をインストールする必要があり、公式文書、その後、DLLを参照します。レセプションは次のとおりです。
<
ASP:テキストボックス
ID
= "txtID"
にrunat
= "サーバー"
> </
ASP:テキストボックス
>
< ASP:AutoCompleteExtender ID = "AutoCompleteExtender1" にrunat = "サーバ" TargetControlID = "txtID" ServicePath = "autoCompExtenderServer.asmx" ServiceMethod =」 GetDataの」CompletionSetCount = "10" FirstRowSelected = "true"をMinimumPrefixLength = "1" > </ ASP:AutoCompleteExtender >
バインドされたテキストボックスTargetControlIDを表します
ServicePath:サービス・パス
ServiceMethod:自動プロンプトメソッド名
CompletionSetCount:ディスプレイの数
FirstRowSelected:自動的に最初のライン・プロンプトを選択するかどうか
MinimumprefixLength:プロンプトが表示されたら、単語の数を入力し始めました。
autoCompExtenderServer.asmx背景コード
使用して
システムを。
使用して System.Collections.Genericを。
使用して System.Linqのを。
使用して のSystem.Webを。
使用して System.Web.Servicesを。
使用して System.Runtime.Serializationを。
使用して System.Web.Script.Serializationを。
名前空間 auotoCompleteText
{
/// <要約> /// autoCompExtenderServer的摘要说明/// </要約> [Webサービス(ネームスペース= " http://tempuri.org/ " )] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(偽
)]
// 欠点のコメントを外し、このスクリプトを呼び出してから、ASP.NET AJAX Webサービスの使用を許可するには。 【System.Web.Script.Services.ScriptService] パブリッククラスautoCompExtenderServer:System.Web.Services.WebService { [WebMethod属性] パブリック文字列[]のGetData(文字列prefixText、int型のCOUNT){ 文字列[]データ= 新しい新しい文字列[ 10000 ]。以下のために(int型I = 0 ;私は< data.length; Iは++ )[I]データ= i.ToString(" 0000
" );
戻り data.Whereした(p => p.IndexOf(prefixText) > = 0 ).Take(カウント).ToArray(); } } }
使用して System.Collections.Genericを。
使用して System.Linqのを。
使用して のSystem.Webを。
使用して System.Web.Servicesを。
使用して System.Runtime.Serializationを。
使用して System.Web.Script.Serializationを。
名前空間 auotoCompleteText
{
/// <要約> /// autoCompExtenderServer的摘要说明/// </要約> [Webサービス(ネームスペース= " http://tempuri.org/ " )] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(偽
)]
// 欠点のコメントを外し、このスクリプトを呼び出してから、ASP.NET AJAX Webサービスの使用を許可するには。 【System.Web.Script.Services.ScriptService] パブリッククラスautoCompExtenderServer:System.Web.Services.WebService { [WebMethod属性] パブリック文字列[]のGetData(文字列prefixText、int型のCOUNT){ 文字列[]データ= 新しい新しい文字列[ 10000 ]。以下のために(int型I = 0 ;私は< data.length; Iは++ )[I]データ= i.ToString(" 0000
" );
戻り data.Whereした(p => p.IndexOf(prefixText) > = 0 ).Take(カウント).ToArray(); } } }
prefixText、変更しないでカウント:2つのパラメータはあることに注意してください。
参考ます。http://moosdau.blog.163.com/blog/static/43711282008824113942459/
ます。https://www.cnblogs.com/xinjian/archive/2010/11/24/1886283.htmlで再現