我正在构建一个 HTTPHandler,它将提供纯文本以供 jQuery Autocomplete 使用。我现在可以使用它,除了当我插入第一个文本时,它不会带我到字母表的正确部分。
示例:如果我输入Ne
我的下拉返回
纳巴马
阿肯色州
注意Ne“Alabama”中的“N”和“labama”
当我键入第三个字符New时,jQuery 返回结果的“N”部分。
我当前的代码看起来像这样
Public Sub ProcessRequest(ByVal context As System.Web.HttpContext) Implements System.Web.IHttpHandler.ProcessRequest
    ''# the page ContentType is plain text
    HttpContext.Current.Response.ContentType = "text/plain"
    ''# store the querystring as a variable'
    Dim qs As Nullable(Of Integer) = Integer.TryParse(HttpContext.Current.Request.QueryString("ID"), Nothing)
    ''# use the RegionsDataContext'
    Using RegionDC As New DAL.RegionsDataContext
        ''# create a (q)uery variable'
        Dim q As Object
        ''# if the querystring PID is not blank'
        ''# then we want to return results based on  the PID'
        If Not qs Is Nothing Then
            ''# that fit within the Parent ID'
            q = (From r In RegionDC.bt_Regions _
                    Where r.PID = qs _
                   Select r.Region).ToArray
            ''# now we loop through the array'
            ''# and write out the ressults'
            For Each item In q
                HttpContext.Current.Response.Write(item & vbCrLf)
            Next
        End If
    End Using
End Sub
所以我现在所处的位置是我偶然发现了 Autocomplete 方法的“ Part ”部分,我应该只返回包含在 Part 中的信息。
我的问题是,如果不对每个字符更改执行新的 SQLQuery,我将如何在我的 HTTPHandler 中实现这个概念?IE:我在QueryString("ID")上执行 SQL 查询,然后在每次后续加载相同 ID 时,我们只过滤掉“Part”。
http://www.example.com/ReturnRegions.axd?ID=[someID]&Part=[string]