<script> function SetContextKey() { debugger if (($('#<%=ddl.ClientID %> option:selected').text()) == "Select") { alert("Select Branch"); return; } $find('<%=AutoCompleteExtender1.ClientID%>').set_contextKey($('#<%=ddl.ClientID %> option:selected').text()); } </script> html <asp:UpdatePanel ID=UpdatePanel1runat=server> <asp:TextBox ID="txt" runat="server" onkeyup="SetContextKey()" placeholder="Type in first two letters" Width="201px" AutoPostBack="True"> <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" ServiceMethod="AutoCompleteBranch" ServicePath="abc.asmx" MinimumPrefixLength="2" CompletionInterval="100" EnableCaching="False" UseContextKey="True" TargetControlID="txt" DelimiterCharacters="" Enabled="True">
[WebMethod] public string[] AutoCompleteBranch(string prefixText, int count, string contextKey) { List<string> ajaxDataCollection = new List<string>(); //_objCommonBO = new CommonBO(); //_objCommonBL = new CommonBL(); //_objCommonBO.BranchName = prefixText; DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter("SP", con); da.SelectCommand.CommandType = CommandType.StoredProcedure; da.SelectCommand.Parameters.AddWithValue("@b", prefixText); da.SelectCommand.Parameters.AddWithValue("@ba", contextKey); dt.Clear(); da.Fill(dt); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { ajaxDataCollection.Add(dt.Rows[i]["BR"].ToString()); } } return ajaxDataCollection.ToArray(); }
da.Fill(dt);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)