Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try the following code this is working example:</p> <pre><code> $(document).ready(function () { $('[ID$=txtPatientLastname]').live('keyup.autocomplete', function () { $(this).autocomplete({ source: function (request, response) { $.ajax({ url: '&lt;%=ResolveUrl("~/Resources/WebService.asmx/GetPatientLastName") %&gt;', data: "{ 'prefix': '" + request.term + "'}", dataType: "json", type: "POST", contentType: "application/json; charset=utf-8", success: function (data) { response($.map(data.d, function (item) { return { label: item.split('-')[0], val: item.split('-')[1] } })) }, error: function (response) { alert(response.responseText); }, failure: function (response) { alert(response.responseText); } }); }, select: function (e, i) { }, minLength: 1 }); }); }); </code></pre> <p>And you can create a webmethod or you can use Web Service as i have done</p> <p>Webservices code:</p> <pre><code>[WebMethod(EnableSession = true)] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string[] GetPatientLastName(string prefix) { List&lt;string&gt; customers = new List&lt;string&gt;(); using (SqlConnection conn = new SqlConnection()) { string connectionstring = CCMMUtility.GetCacheForWholeApplication(); conn.ConnectionString = connectionstring; using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "select distinct top(10) PatientLastname from tblMessage where " + "PatientLastname like '%'+ @SearchText + '%' order by PatientLastname"; cmd.Parameters.AddWithValue("@SearchText", prefix); cmd.Connection = conn; conn.Open(); using (SqlDataReader sdr = cmd.ExecuteReader()) { while (sdr.Read()) { customers.Add(string.Format("{0}", sdr["PatientLastname"])); } } conn.Close(); } return customers.ToArray(); } } </code></pre> <p>Hope this will work for you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload