Hi guys, I'm stuck with this auto-complete problem. I followed an article on this site specifically - http://www.c-sharpcorner.com/UploadFile/raj1979/AutoComplete02142008113654AM/AutoComplete.aspx but then my auto complete does not work. Here is my code in my webservice
C#
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Collections.Generic;
using MySql.Data.MySqlClient;
////// Summary description for acPatientList///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
publicclassacPatientList : System.Web.Services.WebService {
publicacPatientList () {
//Uncomment the following line if using designed components //InitializeComponent();
}
[WebMethod]
publicstring[] GetPatientList(string strPrefixText)
{
MySqlConnection cnDBConnection = new MySqlConnection();
MySqlCommand cmPatientList = new MySqlCommand();
MySqlDataReader rdPatientList;
List result = new List();
cnDBConnection.ConnectionString = clsFunction.strConnection;
cnDBConnection.Open();
cmPatientList.Connection = cnDBConnection;
cmPatientList.CommandText = "SELECT patientid, CONCAT(lname,', ',fname,' ',mname) AS patient " +
"FROM patientlist WHERE lname LIKE '" + clsFunction.ReplaceString(strPrefixText) +
"%'";
rdPatientList = cmPatientList.ExecuteReader();
while(rdPatientList.Read())
{
result.Add(rdPatientList[0].ToString() + "-" + rdPatientList[1].ToString());
}
rdPatientList.Close();
cmPatientList.Connection.Close();
cnDBConnection.Close();
return result.ToArray();
}
}
Using a master page, this is the scripts for my interface...
Code
The code above was written in an ASP.Net Web Site, and it doesn't work in ASP.Net Ajax-Enabled Web Site. Can anyone help me with this issure because, I followed a lot of tutorials and articles but my code does not work.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
boycoto132 reputationPosted Jan 15, 2010, 12:48 PM EST
0
Well, the above code works when I'm going to invoke the web service because there's an XML file that appears which shows the result. However, if I'll be using the request form page and I'll try to press a key...it doesn't give any value at all. I mean, it doesn't act like an auto-complete. There's no list of names that appear.
boycoto132 reputationPosted Jan 15, 2010, 9:18 PM EST
0
But my connection string is working fine because, I can insert, update and delete record. Also, if I'm doing wrong, then, why is it that, there's a return result set when I invoke my GetPatientList method in my web service.
boycoto132 reputationPosted Jan 15, 2010, 12:48 PM EST
boycoto132 reputationPosted Jan 15, 2010, 9:18 PM EST