ajax auto complete extender....coding

Posted by Ankitsrist under ASP.NET AJAX category on | Points: 40 | Views : 1555
here i will explain how i have implemented ajax auto complete extender.....it is very useful for beginners nd m also fresher so i understand the problem which we generally face during programming...here is the .aspx page
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
 <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" ServicePath= "WebService.asmx" ServiceMethod="GetCountries" MinimumPrefixLength="1" EnableCaching="true" CompletionSetCount="1" TargetControlID="TextBox1">

nd below is the webservice.asmx page which u can simply include by right click on ur website....
using System.Web.Services.Protocols;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public class WebService : System.Web.Services.WebService
public WebService()
//Uncomment the following line if using designed components

Class1 db=new Class1 ();
public List<string>GetCountries(string prefixText)
db.mycon ();
SqlCommand cmd = new SqlCommand("select * from stuloginstoreproc where name like @name+'%'", db.con );
cmd.Parameters.AddWithValue("@name", prefixText);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
List<string> CountryNames = new List<string>();
for (int i = 0; i < dt.Rows.Count; i++)
return CountryNames;

happy coding frnds

Comments or Responses

Login to post response