Hi,
I have a textbox and autoextender that will allow a search through my database for product names. I need the product name that is chosen to link to it's page. Is it possible to do this without adding a submit button? It won't fit next to my search and it wouldn't look right if I put one there anyway. I want the client side scripting in jquery..Its urgent pls anyone reply me immediately ..i want the soln ..
<
ajaxToolkit:ToolkitScriptManager runat="server" ID="ScriptManager1" ></ajaxToolkit:ToolkitScriptManager>
<div>
<asp:TextBox runat="server" ID="myTextBox" Width="300" CssClass="stylesheet" autocomplete="off" />
<ajaxToolkit:AutoCompleteExtender
runat="server"
BehaviorID="AutoCompleteEx"
ID="autoComplete1"
TargetControlID="myTextBox"
ServicePath="AutoComplete.asmx"
ServiceMethod="GetCompletionList"
MinimumPrefixLength="1"
CompletionInterval="10"
EnableCaching="true"
CompletionSetCount="20"
CompletionListCssClass="autocomplete_completionListElement"
CompletionListItemCssClass="autocomplete_listItem"
CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
DelimiterCharacters=";, :"
ShowOnlyCurrentWordInCompletionListItem="true" >
<WebMethod()> _
public
string[] GetCompletionList(string prefixText, int count)
{
//ADO.Net
SqlConnection cn =new SqlConnection();
DataSet ds = new DataSet();
DataTable dt = new DataTable();
//String strCn = "data source=.;Initial Catalog=MyDB;Integrated Security=True";
String strCn ="Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\vsubram\\Documents\\Visual Studio 2010\\WebSites\\AutoDB\\App_Data\\Database.mdf;Integrated Security=True;User Instance=True";
//Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Users\vsubram\Documents\Visual Studio 2010\WebSites\AutoDB\App_Data\Database.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True
cn.ConnectionString = strCn;
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandType =
CommandType.Text;
//Compare String From Textbox(prefixText) AND String From Column in DataBase(CompanyName)
//If String from DataBase is equal to String from TextBox(prefixText) then add it to return ItemList
//-----I Defined a parameter instead of passing value directly to prevent sql injection--------//
cmd.CommandText = "select * from tblCustomer Where CompanyName like @myParameter";
cmd.Parameters.AddWithValue("@myParameter", "%" + prefixText + "%");
try
{
cn.Open();
cmd.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
}
catch
{
}
finally
{
cn.Close();
}
dt = ds.Tables[0];
//Then return List of string(txtItems) as result
List<string> txtItems =new List<string>();
String dbValues;
foreach (DataRow row in dt.Rows)
{
//String From DataBase(dbValues)
dbValues = row["CompanyName"].ToString();
dbValues = dbValues.ToLower();
txtItems.Add(dbValues);
}
return txtItems.ToArray();
}