Get Selected Item Value from jQuery Autocomplete TextBox on KeyBoard arrow selection in ASP.Net

Last Reply 10 months ago By dharmendr

Posted 10 months ago

I am using Jquery UI auto complete plugin. My Auto complete textbox correctly updates the result when i use Mouse hover select and hit enter. but when i use keyboard down arrow to select the autocomplete result and hitting enter returns empty string.  how do i fix this?

Posted 10 months ago

Hi manionasp,

Refer the below article. It working with Mouse hover selection and  keyboard down arrow selection.

Get Selected Item Value from jQuery Autocomplete TextBox in ASP.Net using C# and VB.Net

C#

protected void Submit(object sender, EventArgs e)
{
    string customerName = Request.Form[txtSearch.UniqueID];
    string customerId = Request.Form[hfCustomerId.UniqueID];
    ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('Name : " + customerName + "\\nId : " + customerId + "')", true);
}

VB.Net

Protected Sub Submit(ByVal sender As Object, ByVal e As EventArgs)
    Dim customerName As String = Request.Form(txtSearch.UniqueID)
    Dim customerId As String = Request.Form(hfCustomerId.UniqueID)
    ClientScript.RegisterClientScriptBlock(Me.[GetType](), "", "alert('Name : " & customerName & "\nId : " & customerId & "')", True)
End Sub

Screenshot