boycoto

boycoto

  • NA
  • 147
  • 125.5k

Auto-Complete not working...

Jan 15 2010 9:09 AM
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
 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>
/// Summary description for acPatientList
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class acPatientList : System.Web.Services.WebService {

public acPatientList () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public string[] GetPatientList(string strPrefixText)
{
MySqlConnection cnDBConnection = new MySqlConnection();
MySqlCommand cmPatientList = new MySqlCommand();
MySqlDataReader rdPatientList;

List <string> result = new List<string>();

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...
 <asp:ScriptManager ID="ScriptManager" runat="server">
<Services>
<asp:ServiceReference Path="acPatientList.asmx" />
</Services>
</asp:ScriptManager>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender" runat="server" ServiceMethod="GetPatientList"
ServicePath="acPatientList.asmx" MinimumPrefixLength="1" TargetControlID="txtPatientName" CompletionSetCount="10" EnableCaching="true">
</cc1:AutoCompleteExtender>
<asp:Label ID="Label1" runat="server" Text="Request ID:" Width="87px"></asp:Label><asp:TextBox
ID="txtRequestID" runat="server" BackColor="White" Font-Bold="True" ReadOnly="True"></asp:TextBox>
<br />
<asp:Label ID="Label3" runat="server" Text="Patient Name:" Width="87px"></asp:Label><asp:TextBox
ID="txtPatientName" runat="server" Width="303px" BackColor="White"></asp:TextBox><br />
<asp:Label ID="Label4" runat="server" Text="Requested By:" Width="87px"></asp:Label><asp:TextBox
ID="txtRequestedBy" runat="server" Width="303px" BackColor="White"></asp:TextBox>&nbsp;</div>

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.

Answers (2)