2015-06-18 56 views
2

現在我有一個在ASP.NET 4.5中的autoCompleteExtender中添加滾動條的問題。 我想開發自動完成系統添加滾動條的文本框。 但是,正如下面的代碼,我不能讓滾動條添加自動完成系統在ASP.NET 4.5的AutoCompleteExtender中添加滾動條

我的代碼是繼

ASPX & CS文件

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AutoCompletEextender.aspx.cs" Inherits="AutoCompleteTest6.AutoCompletEextender" %> 

    <!DOCTYPE html> 

    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head runat="server"> 
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
     <title></title> 
    </head> 
    <body> 
     <form id="form1" runat="server"> 
      <asp:ScriptManager ID="ScriptManager1" runat="server"> 
      </asp:ScriptManager> 
      <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
      <ajaxToolkit:AutoCompleteExtender 
       ID="TextBox1_AutoCompleteExtender" 
       runat="server" 
       CompletionInterval="50" 
       CompletionSetCount="40" 
       EnableCaching="False" 
       MinimumPrefixLength="0" 
       ServiceMethod="GetAutoCompTestListAAAA" 
       ServicePath="AutoCompList.asmx" 
       TargetControlID="TextBox1"> 
      </ajaxToolkit:AutoCompleteExtender> 
     </form> 
    </body> 
    </html> 



using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.Services; 

namespace AutoCompleteTest6 
{ 
    [WebService(Namespace = "http://tempuri.org/")] 
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 
    [System.ComponentModel.ToolboxItem(false)] 
    [System.Web.Script.Services.ScriptService] 
    public class AutoCompList : System.Web.Services.WebService 
    { 

     [WebMethod] 
     public string[] GetAutoCompTestListAAAA(string prefixText, int count) 
     { 
      string[] aAutoComp = new string[]{ 
      "ActionScript", 
      "AppleScript", 
      "Asp", 
      "BASIC", 
      "C", 
      "C++", 
      "Clojure", 
      "COBOL", 
      "ColdFusion", 
      "Erlang", 
      "Fortran", 
      "Groovy", 
      "Haskell", 
      "Java", 
      "JavaScript", 
      "Lisp", 
      "Perl", 
      "PHP", 
      "Python", 
      "Ruby", 
      "Scala", 
      "Scheme"}; 

      string[] filterdList = aAutoComp.Where(str => (0 <= str.IndexOf(prefixText, StringComparison.CurrentCultureIgnoreCase))).ToArray(); 
      return filterdList; 
     } 
    } 
} 

建立後,自動完成功能不顯示滾動條。 請教我。

回答

1

添加一個div來保存y軸上的滾動溢出列表元素將有助於自動完成擴展。

請嘗試以下更改aspx頁面:

<!DOCTYPE html> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title></title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
     <asp:ScriptManager ID="ScriptManager1" runat="server"> 
     </asp:ScriptManager> 
     <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
     <div id="listPlacement" style="height:100px; overflow-y:scroll;" ></div> 
     <ajaxToolkit:AutoCompleteExtender 
      ID="TextBox1_AutoCompleteExtender" 
      runat="server" 
      CompletionInterval="50" 
      CompletionSetCount="40" 
      CompletionListElementID="listPlacement" 
      EnableCaching="False" 
      MinimumPrefixLength="0" 
      ServiceMethod="GetAutoCompTestListAAAA" 
      ServicePath="AutoCompList.asmx" 
      TargetControlID="TextBox1"> 
     </ajaxToolkit:AutoCompleteExtender> 
    </form> 
</body> 
</html> 
+0

謝謝你回答我的問題!我可以在AutoCompleteExtender中添加滾動條。 – Ryo

+0

救了我的一天!我欠你一個人情 :) – Ange1