Is there a way to add name/value functionality to jquery autocomplete for .net?
Posted
by Mark Kadlec
on Stack Overflow
See other posts from Stack Overflow
or by Mark Kadlec
Published on 2009-07-16T16:09:29Z
Indexed on
2010/05/24
1:01 UTC
Read the original article
Hit count: 385
I've recently added the JQuery autocomplete plug in and have a textbox that autocompletes a list of employees. It works great and I commend the authors of the plugin.
I think the textbox would be MUCH more useful though, when upon selecting, we can extract the StaffID (Ie. retreive the value of the selection). My code is below and you can see that I am simply adding the staff names, would be nice to associate IDs.
Does anyone know of any way to do this?
My JQuery:
$(document).ready(function() {
$("#txtStaff").autocomplete('autocompletetagdata.aspx');
});
My ASPX page:
protected void Page_Load(object sender, EventArgs e)
{
StaffViewListClass staffList = StaffViewListClass.GetStaff();
StringBuilder sb = new StringBuilder();
foreach (StaffViewClass staff in staffList)
{
sb.Append(staff.FullName).Append("\n");
}
Response.Write(sb.ToString());
}
© Stack Overflow or respective owner