0

修正済み: プロパティ CompletionInterval="0" の欠落

ajax オートコンプリート エクステンダーと Web サービスの機能をテストしています。そして、オートコンプリートエクステンダーがデータを取得して表示するのに時間がかかることがわかりました。現在、データベース接続などはありません。すべてのアイテムを webservice 関数の配列に入れ、LINQ を使用して一致するアイテムのセットを返します。データを表示する約 1 秒のギャップがあります。EnableCaching をオン/オフしてみましたが、誰かがブログでそれを示唆しているのを見つけましたが、Google が数十億のデータを検索し、何十億ものユーザーがいるライブ Web サイトで結果を 1 秒の遅延もなく返す方法を比較すると、まだ非常に遅いです。

Google は asp.net、Linq、またはスクリプト マネージャーを使用して Ajax の作業を行うことはありませんが、データベースに接続せずにローカル コンピューターでテストしているだけなので、動作を高速化する方法があるはずだと思います。おそらくどこかで設定をし忘れていたのでしょう。これが私のコードです。

aspx

    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>

    <asp:TextBox ID="TextBox1" runat="server" Width="200px"></asp:TextBox>

    <asp:AutoCompleteExtender ID="TextBox1_AutoCompleteExtender" runat="server" ServiceMethod="HelloWorld" MinimumPrefixLength="1" EnableCaching="false" CompletionListCssClass="CompletionListCssClass"
    DelimiterCharacters="" Enabled="True" ServicePath="WebService.asmx" TargetControlID="TextBox1"> 
    </asp:AutoCompleteExtender>
    <br />
    <asp:Button ID="Button1" runat="server" Text="Search" />

code_behind には何もありません。

これがWebサービスのコードです..

    <System.Web.Script.Services.ScriptService()> _
    <WebService(Namespace:="http://tempuri.org/")> _
    <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Public Class WebService
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function HelloWorld(prefixText As String) As String()

    Dim str() As String = {"Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan",
                            "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei",
                            "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Central African Republic",
                            "Chad", "Chile", "China", "Colombi", "Comoros", "Congo (Brazzaville)", "Congo", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Cyprus",
                            "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor (Timor Timur)", "Ecuador", "Egypt", "El Salvador",
                            "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Fiji", "Finland", "France", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana",
                            "Greece", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Hungary", "Iceland", "India", "Indonesia",
                            "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North",
                            "Korea, South", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania",
                            "Luxembourg", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius",
                            "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepa", "Netherlands",
                            "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay",
                            "Peru", "Philippines", "Poland", "Portugal", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent",
                            "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore",
                            "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland",
                            "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda",
                            "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan", "Vanuatu", "Vatican City", "Venezuela", "Vietnam",
                            "Yemen", "Zambia", "Zimbabwe"}

    Dim result As ArrayList = Nothing

    Dim query = From x In str
                Where x.ToLower.Contains(prefixText)
                Select x

    Return query.ToArray

    End Function

    End Class
4

2 に答える 2

3

AutoCompleteExtender に遅延プロパティはありませんか? CompletionInterval だと思います。

于 2012-05-30T08:46:18.163 に答える