STEP 1:
First of all add ajaxTool element in codebehind
of program.
Take a textbox as shown below and then add the AjaxToolKit element with this textbox.
<asp:TextBox ID="txtCatgrySerch" runat="server" OnTextChanged="txtCatgrySerch_TextChanged"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender runat="server" ID="AutoCompleteExtender1" TargetControlID="txtCatgrySerch"
MinimumPrefixLength="1" CompletionInterval="100" EnableCaching="false" CompletionSetCount="10"
FirstRowSelected="false" ServiceMethod="GetName" />
Instruction To Use:
Write the TextBox
id in TargetControlID and the Method Name That
showing Below in ServiceMethod as shown above.
STEP 2:
public partial class Form_XYZ : System.Web.UI.Page
{
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> GetName(string prefixText)
{
dbConnection cn = new dbConnection();
cn.CreateObject();
using (MySqlDataAdapter adp = new MySqlDataAdapter("ProcedureName", ConnectionString))
{
List<string> E_NAME2 = new List<string>();
adp.SelectCommand.CommandType
= CommandType.StoredProcedure;
adp.SelectCommand.Parameters.AddWithValue("@SearchItem",
prefixText);
DataTable dt = new DataTable();
adp.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{
E_NAME2.Add(dt.Rows[i][0].ToString());
}
return E_NAME2;
}
}
}
Instruction To Use:
a)
Make Procedure for searching records from
specific table on any condition.
b)
In this method Typed keyword will automatically
pass in this method and will show the result.
c)
Important Note: Inside this method any server
control will not work, you will unable to see the controls. In this case you can add HttpContext.Current.Session["AnyName"] for maintaing Session
or anything else.
RESULT :
