0

主页表格

<form id="form1" runat="server">
    Search your keyword
    <asp:TextBox ID="search" onkeydown="javascript:doAJAX(this.value)"  runat="server">
    </asp:TextBox>
</form>

这是文本框搜索关键字的代码。当一个键被按下时,我的代码正在发送上一个输入的键。如何获取当前密钥?该doAJAX函数又调用另一个 aspx 页面并填充此页面。

Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

    Try
        'Response.ContentType = "application/xhtml+xml"
        'Build CategoriesList
        Dim strSQL As String
        Dim Mytable As DataTable
        strSQL = "exec GetAJAXSearchResults '"
        strSQL &= Request("keyword")
        strSQL &= "', " & AppSettings("SiteId")
        Mytable = myLib.GetData(strSQL)



        For Each row As DataRow In Mytable.Rows
            'strChartList &= row.Item("title") & "<br/>"
            strChartList &= row.Item("PID") & "  " & row.Item("title") & "<br/>"
        Next row

        strChartList &= "</p>"

这是具有过程详细信息的 aspx 代码...我尝试在 for 之前放置一个 if 语句..但没有工作..

4

1 回答 1

3

更改onkeydown为,onkeyup以便在内容更改后触发

请参阅此链接。事件顺序:keydown(符号尚未插入)、keypress(符号插入的时刻)、keyup - 符号插入后

'Response.ContentType = "application/xhtml+xml"
    'Build CategoriesList
    Dim strSQL As String
    Dim Mytable As DataTable
    strSQL = "exec GetAJAXSearchResults '"
    strSQL &= Request("keyword")
    strSQL &= "', " & AppSettings("SiteId")
    strChartList &= "<p>" // see no opening tag in your code.
    If Not String.IsNullOrEmpty(Request("keyword")) And Request("keyword").Length() > 1 Then
      Mytable = myLib.GetData(strSQL)



       For Each row As DataRow In Mytable.Rows
          'strChartList &= row.Item("title") & "<br/>"
          strChartList &= row.Item("PID") & "  " & row.Item("title") & "<br/>"
      Next row
    End If
    strChartList &= "</p>"

应该像上面那样。对不起,如果语句不是来自 VB,我只是不记得它在 VB 中应该是什么样子的细节。希望你能把 C# if 翻译成 VB if

于 2012-09-05T12:15:03.660 回答