主页表单
<form id="form1" runat="server">
Search your keyword
<asp:TextBox ID="search" onkeydown="javascript:doAJAX(this.value)" runat="server">
</asp:TextBox>
</form>
这是文本框搜索关键字的代码。按下某个键后,我的代码将发送输入的上一个键。我如何获得当前密钥? doAJAX
函数inturn调用另一个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代码,其中包含程序详细信息...我试图在if ...之前添加一个if语句但是没有工作..
答案 0 :(得分:3)
将onkeydown
更改为onkeyup
,以便在内容更改后触发
见link。事件顺序:keydown(尚未插入符号),按键(插入符号的时刻),键盘 - 插入符号后
'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,如果