Click here to Skip to main content
15,911,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My code is Here..
----------------------------------------------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Emp.aspx.cs" Inherits="Emp" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server" style="background-color:tan">

<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server">
<services>
<asp:ServiceReference Path="~/WebService.asmx" />







<asp:Label ID="Label1" runat="server" style="z-index: 1; left: 298px; top: 157px; position: absolute; bottom: 324px;" Text="Enter Name:">
<asp:TextBox ID="TextBox1" runat="server" AutoCompleteType="Disabled" style="z-index: 1; left: 424px; top: 158px; position: absolute; width: 217px;">
<ajax:AutoCompleteExtender ID="AutoCompleteExtender1" MinimumPrefixLength="1" TargetControlID="TextBox1" EnableCaching="true" UseContextKey="True" CompletionSetCount="10" CompletionInterval="1000" ServiceMethod="getValue" ServicePath="~/WebService.asmx" runat="server">
<asp:GridView ID="GridView1" runat="server" style="z-index: 1; left: 420px; top: 213px; position: absolute; height: 207px; width: 316px">

</form>
</body>

</html>

---------------------------------------------------------------------

webService.cs



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Web.Script.Services;
using AjaxControlToolkit;
using System.Web.Services;
//
/// Summary description for WebService
///

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// 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 WebService : System.Web.Services.WebService {

public WebService () {

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

public string HelloWorld() {
return "Hello World";
}



#region "Getting all value "
[WebMethod]
public static String[] getValue(string prefixText, int count)
{
DataClassesDataContext dt = new DataClassesDataContext();
var autocompleteData = from data in dt.Emp_Details.Where(U => U.Name.Contains(prefixText)) select data.Name;
System.Console.Write("DATA:" + autocompleteData);
return autocompleteData.ToArray();
}
#endregion


[WebMethod]
public List<string> getAllValue()
{
DataClassesDataContext dt = new DataClassesDataContext();
var autocompleteData = from x in dt.Emp_Details select x.Name;
System.Console.Write("DATA:" + autocompleteData);
return autocompleteData.ToList();
}

}



/// Give Me a Solution...
Posted

1 solution

<asp:autocompleteextender id="auotComplete" runat="server" enablecaching="true" behaviorid="AutoCompleteEx" xmlns:asp="#unknown">
MinimumPrefixLength="2" TargetControlID="txtName" ServiceMethod="GetCompletionList"
CompletionInterval="1000" CompletionSetCount="20" CompletionListCssClass="autocomplete_completionListElement"
CompletionListItemCssClass="autocomplete_listItem" CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
DelimiterCharacters=";, :" ShowOnlyCurrentWordInCompletionListItem="true">
<animations>
<onshow>
<sequence>
<opacityaction opacity="0">
<hideaction visible="true">
<scriptaction script="// Cache the size and setup the initial size<br mode=" hold=" /> var behavior = $find('AutoCompleteEx');<br mode=">
<parallel duration=".4">
<fadein>
<length propertykey="height" startvalue="0">
EndValueScript="$find('AutoCompleteEx')._height" />



<onhide>
<parallel duration=".4">
<fadeout>
<length propertykey="height" startvaluescript="<br" mode="hold"> "$find('AutoCompleteEx')._height" EndValue="0" />






<system.web.script.services.scriptmethod()> _
<system.web.services.webmethod()> _
Public Shared Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer) As List(Of String)
Dim SQL As String = ""
SQL = SQL & vbCrLf & " select top 15 name from v_employees "
SQL = SQL & vbCrLf & " where name like '%' + @name + '%' order by name "
Dim ds As DataSet
Dim txtData As New List(Of String)
Dim param As SqlParameter = New SqlParameter("@name", prefixText)
ds = SqlHelper.ExecuteDataset(WebGlobalVariables.Connection, CommandType.Text, SQL, param)
If ds.Tables(0).Rows.Count > 0 Then
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
txtData.Add(ds.Tables(0).Rows(i).Item("name").ToString.ToLower)
Next
End If
Return txtData
End Function
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900