Donate

Using AJAX Control Toolkit AutoCompleteExtender In ASP.NET 4.5 Web Forms

Hello all,
I have posted in VBForums codebank on how to integrate Ajax Toolkit's AutoCompleteExtender control in your ASP.NET 4.5 Web Forms project. The thread is in VB.NET but if your using C# just replace the code behind as described in Step 4 with the snippet below.
Code Behind
private static AdventureWorks2012Entities _context;

[ScriptMethod()]
[WebMethod]
public static List<string> GetCountries(string prefixText, int count)
{
 _context = new AdventureWorks2012Entities();

 var result = (from country in _context.CountryRegions.AsEnumerable()
      where country.Name.ToLower().StartsWith(prefixText, StringComparison.OrdinalIgnoreCase)
      select country.Name).Take(count);

 return result.ToList();
}

[ScriptMethod()]
[WebMethod]
public static object GetCountryInfo(string Country)
{
 _context = new AdventureWorks2012Entities();

 var result = (from country in _context.CountryRegions.AsEnumerable()
      where country.Name.ToLower().Equals(Country.ToLower())
      select new 
      { 
       country.Name, 
       country.CountryRegionCode
      }).FirstOrDefault();

 return result;
}

Screenshot
Using AJAX Control Toolkit AutoCompleteExtender in ASP.NET

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.