Hi all,
I have a textbox with the autocompleteextender in VS2012 that is referencing a webservice. However, nothing I seem to do makes this work as no values are returned when I begin typing in the textbox. When I view the webservice in my browser and invoke it, it returns values so I know that my webservice works. Code below
Design
Webservice Part.
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class studentcurrent : System.Web.Services.WebService
{
[WebMethod]
public string[] GetCompletionListPresent(string prefixText, int count)
{
DataSet ds = new DataSet();// but it does not do one by one
DataTable dt = new DataTable();//it checks one by one
string a = System.Configuration.ConfigurationManager.ConnectionStrings["smsonline"].ToString();
SqlConnection thisConnection = new SqlConnection(a);
SqlCommand cmd = new SqlCommand();
cmd.Connection = thisConnection;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "WITH clean_cte AS(select CASE " +
" when (CC.transfercert=0 and CC.promoted=0) then (RTRIM(SP.studentfirstname) + ' ' + RTRIM(SP.studentlastname))+ '/'+ " +
" CONVERT(varchar(10),RTRIM(Y.years)) + '/' + CONVERT(varchar(20),RTRIM(CL.classname))+ ' ' + UPPER(CC.secdiv) end as Details " +
" from TBL_Student_CurrentClassDet CC inner join TBL_Student_PersonalDetails SP on CC.regno = SP.regno inner join TBL_MasterYear Y on CC.yearid = Y.yearid " +
" inner join TBL_Student_ClassDetails CD on CC.regno = CD.regno inner join TBL_MasterClass CL on CC.classid = CL.classid where " +
" (SP.studentfirstname like @myParameter or SP.studentlastname like @myParameter or Y.years like @myParameter or CL.classname like @myParameter)) select * from clean_cte where Details is not null";
cmd.Parameters.AddWithValue("@myParameter", prefixText + "%");
try
{
thisConnection.Open();
cmd.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
}
catch (Exception ex)
{
}
finally
{
thisConnection.Close();
}
dt = ds.Tables[0];
//Then return List of string(txtItems) as result
List
String dbValues;
foreach (DataRow row in dt.Rows)
{
//String From DataBase(dbValues)
dbValues = row["Details"].ToString();
dbValues = dbValues.ToLower();
txtname.Add(dbValues);
}
return txtname.ToArray();
}
}
[System.ComponentModel.ToolboxItem(false)]
I don't no what does this line does. when i commented it, nothing change.
My Webservice is not inside the App Code folder.. its Individual file. its in the parent folder.
eg: studentcurrent.asmx and my code file is studentcurrent.asmx.cs
The Event is not firing at all. Have Put the Breakpoint too.. but nothing is happening.. When I just run the webservice it works fine.. but thru autocompleteextender its not firing.
Please Help
ChintanPosted Apr 2, 2014, 5:08 AM
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
You can also see in the web.config file that it has been registered they too...
Thanks
saurabh mittalPosted Apr 2, 2014, 4:56 AM
Have u registered ajax file or not like this -
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajax" %>
bbecause in ur code it is not there
thanks
ChintanPosted Apr 2, 2014, 4:18 AM
ChintanPosted Apr 2, 2014, 4:16 AM
saurabh mittalPosted Apr 2, 2014, 3:25 AM
You can check this file. in this autocomplete with jquery and ajax both are there.
you can try any one. check attachment file.
thanks