<script type = "text/javascript"> function Employees_Populated(sender, e) { var employees = sender.get_completionList().childNodes; for (var i = 0; i < employees.length; i++) { var div = document.createElement("DIV"); div.innerHTML = "<img style = 'height:50px;width:50px' src = '~Chrysanthemum.jpg/" + employees[i]._value + ".jpg' /><br />"; employees[i].appendChild(div); } } function OnEmployeeSelected(source, eventArgs) { var idx = source._selectIndex; var employees = source.get_completionList().childNodes; var value = employees[idx]._value; var text = employees[idx].firstChild.nodeValue; source.get_element().value = text; } </script>
[System.Web.Script.Services.ScriptMethod()] [System.Web.Services.WebMethod] public static List<string> SearchEmployees(string prefixText, int count) { using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = ConfigurationManager .ConnectionStrings["GHISConnectionString"].ConnectionString; using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "select photo, FirstName,LastName, RegistrationNo from" + " PatientRegistration where FirstName like @SearchText + '%'"; cmd.Parameters.AddWithValue("@SearchText", prefixText); cmd.Connection = conn; conn.Open(); List<string> employees = new List<string>(); using (SqlDataReader sdr = cmd.ExecuteReader()) { while (sdr.Read()) { employees.Add(AjaxControlToolkit.AutoCompleteExtender .CreateAutoCompleteItem(string.Format("{0} {1} {2}", sdr["FirstName"], sdr["LastName"], sdr["photo"]), sdr["photo"].ToString())); } } conn.Close(); return employees; } } }</string></string></string>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)