I am trying to create an autocomplete textbox.
Stored Procedure
alter proc usp_test_autocomplete
@Distancedetails varchar(50)
as
begin
select top 10 first_name from tbl_user_master where first_name like @Distancedetails +'%'
end
Front end
i copied the jquery js files. and pasted 3 js files on my aspx page.
<script src="../../jQuery/js/jquery-1.9.1.js" type="text/javascript"></script>
<link href="../../jQuery/css/jquery-ui-1.10.3.custom.min.css" rel="stylesheet" type="text/css" />
<script src="../../jQuery/js/jquery-ui-1.10.3.custom.min.js" type="text/javascript"></script>
then
------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%HeaderHTML("Approving Km", 2, 0);%>
<%----%>
<link href="../../Utility/Style/TMS.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="../../jQuery/js/jquery-1.9.1.js" type="text/javascript"></script>
<link href="../../jQuery/css/jquery-ui-1.10.3.custom.min.css" rel="stylesheet" type="text/css" />
<script src="../../jQuery/js/jquery-ui-1.10.3.custom.min.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
$(function() {
$("#<%=txtautocomplete.ClientID%>").autocomplete({
source: function(request, response) {
$.ajax({
url: "WebService.asmx/GetEntireNameDetails",
data: "{ 'Namedetails': '" + request.term + "' }",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function(data) {
response(data.d);
},
error: function(result) {
alert('incorrect result');
}
});
}
});
});
</script>
------------------------------------------------
i created a web service . When i created web service
webservice.cs
got created in
App_code
.
the service i wrote is
[System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService
{
[WebMethod]
public List<string> GetEntireNameDetails(string Namedetails)
{
DataSet ds = null;
TMSDatabase TMSComponent = null;
List<string> list = new List<string>();
try
{
TMSComponent = TMSDatabase.CreateInstance();
ds = TMSComponent.ExecuteStoredProc("usp_test_autocomplete", new TMSDbParameter("@Distancedetails", Namedetails));
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
list.Add(ds.Tables[0].Rows[i]["first_name"].ToString());
}
}
catch
{
}
finally
{
if (TMSComponent != null)
{
TMSComponent.CloseConnection();
TMSComponent = null;
}
}
return list;
}
}
when i viewed the web service in browser and invoked i was getting the correct result in xml
But when i tried to run the code and pass something in the textbox i did not get the correct result. I got the error message : incorrect result
kindly explain me where i am doing wrong.