Hi How we can filter the results according with the input of of a textbox like Google search. i.e, If i enter "alaska airlines", then it filtered and showed result according with our input. How it possible. Please help me. thanks in advnce..
A:
On search click event bind the grid or any controls where you want to populate the result through the database query using like keyword by passing the textbox value as input parameter
Bala
2010-09-16 06:51:25
+1
A:
If I understand correctly you want some form of autocomplete as the user types in your input box.
To achieve this you should use ajax, and the ASP.Net Ajax Toolkit might be what you are looking for. Check out the sample and docs at http://www.asp.net/ajax/ajaxcontroltoolkit/samples/autocomplete/autocomplete.aspx.
Here's a sample for VS2010 and using ASP.Net Toolkit 4.
Markup
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:TextBox runat="server" ID="myTextBox" autocomplete="off" />
<asp:autocompleteextender runat="server" behaviorid="AutoCompleteEx" id="autoComplete1"
targetcontrolid="myTextBox" servicepath="AutoComplete.asmx" servicemethod="GetCompletionList"
minimumprefixlength="2" completioninterval="1000" enablecaching="true" completionsetcount="20"></asp:autocompleteextender>
</div>
</form>
</body>
</html>
AutoComplete.asmx.cs
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class AutoComplete : WebService
{
public AutoComplete()
{
}
[WebMethod]
public string[] GetCompletionList(string prefixText, int count)
{
if (count == 0)
{
count = 10;
}
if (prefixText.Equals("xyz"))
{
return new string[0];
}
Random random = new Random();
List<string> items = new List<string>(count);
for (int i = 0; i < count; i++)
{
char c1 = (char)random.Next(65, 90);
char c2 = (char)random.Next(97, 122);
char c3 = (char)random.Next(97, 122);
items.Add(prefixText + c1 + c2 + c3);
}
return items.ToArray();
}
}
Mikael Svenson
2010-09-16 06:54:06