ASP.NET TextBox With JQuery AutoComplete

i am using JQuery UI Autocomplete with asp.net textbox. AutoComplete works right. but how can i assign selected ID of returned Data to an hiddenField? My server Side Function returned list of objects that contains (this is an example) : public List GetEmployeeList() List empList = new List(); empList.Add(new Employee() ID = 1, Email = “Mary@somemail.com” ); …

via Asp.Net Developed Tutorials » Search Results » ajax:

ASP.NET TextBox With JQuery AutoComplete

i am using JQuery UI Autocomplete with asp.net textbox. AutoComplete works right. but how can i assign selected ID of returned Data to an hiddenField? My server Side Function returned list of objects that contains (this is an example) :
public List GetEmployeeList()

List empList = new List();
empList.Add(new Employee() ID = 1, Email = “Mary@somemail.com” );
empList.Add(new Employee() ID = 2, Email = “John@somemail.com” );
empList.Add(new Employee() ID = 3, Email = “Amber@somemail.com” );
empList.Add(new Employee() ID = 4, Email = “Kathy@somemail.com” );
empList.Add(new Employee() ID = 5, Email = “Lena@somemail.com” );
empList.Add(new Employee() ID = 6, Email = “Susanne@somemail.com” );
empList.Add(new Employee() ID = 7, Email = “Johnjim@somemail.com” );
empList.Add(new Employee() ID = 8, Email = “Jonay@somemail.com” );
empList.Add(new Employee() ID = 9, Email = “Robert@somemail.com” );
empList.Add(new Employee() ID = 10, Email = “Krishna@somemail.com” );

return empList;
}and this is ASPX Code :








here is my jquery Code :
And this is My WEb Method Side Code :
_
Public Shared Function FetchEmailList(ByVal mail As String) As List(Of Employee)
Dim emp = New Employee()
Dim fetchEmail = emp.GetEmployeeList()
Return fetchEmail
End Function

………………………………………

You could subscribe to the success event and grab the ID from ui.item.id like so
select: function( event, ui )
// now assign the id of the selected element into your hidden field
$(“#<%= hidid.ClientID %>“).val( ui.item.id );

I got a hold of the hidid field in a bit of a hackish way (I can’t remember what the preferred way to do it is) so that’s an area of improvement, but this should point you in the right direction.

For more info: ASP.NET TextBox With JQuery AutoComplete

Asp.Net Developed Tutorials » Search Results » ajax

ASP.NET TextBox With JQuery AutoComplete

Share this post:

Related Posts

Leave a Comment