Click here to Skip to main content
15,942,449 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have one drop down box with states and Another one is Text box(Name)...I used auto complete extender for getting names..it's working..but i wanna to search with State and Name(Text box)..how can i pass these two values to back end.auto complete extender is not allowing couple of values..please help me in this regard...

Thanks,
K.Ramakrishna
Posted
Updated 3-Aug-12 0:33am
v2
Comments
Ankur\m/ 3-Aug-12 6:23am    
Do you mean the search text should be something like 'SelectedStateName TextTypedInTextBox' ?
.net333 3-Aug-12 6:34am    
yes..if i select state and Typed like 'a' in textbox so i'll get particular EmployeeNames for that state
.net333 4-Aug-12 4:35am    
I solved this problem using contextKey

You should try with Autocomplete with multiple fields[^].

Refer the links below:
Here[^] is an video for that.


--Amit
 
Share this answer
 
I solved this problem by using context key..

Here is the solution:
write this code in source file
XML
<script type="text/javascript">
            function pageLoad() {
                $addHandler($('ddlpState'), 'change', setcontext);
            }
            function setContext(event) {
                $find('txtprovidernames_AutoCompleteExtender').set_contextKey(event.target.value);
            }
</script>

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

XML
<asp:DropDownList ID="ddlpState" CssClass="companyprofile_formdropdown" AutoPostBack="true"
                    runat="server" Width="290px" Height="30px"
                    onselectedindexchanged="ddlpState_SelectedIndexChanged">
                                       </asp:DropDownList>


XML
<asp:TextBox ID="txtprovidernames" runat="server" autocomplete="off"
                   CssClass="productmanagement_formtext"></asp:TextBox>

XML
<ajax:AutoCompleteExtender ID="txtprovidernames_AutoCompleteExtender"  MinimumPrefixLength="1"
                         runat="server" DelimiterCharacters="" Enabled="True" EnableCaching="true" ServicePath="~/AutoComplete.asmx" ServiceMethod="GetEmployeeNamesByState"
                  TargetControlID="txtprovidernames" UseContextKey="true">
              </ajax:AutoCompleteExtender>

----------------------------------------------------------
This is the dropdown selected index changed:
C#
protected void ddlpState_SelectedIndexChanged(object sender, EventArgs e)
   {
       txtprovidernames_AutoCompleteExtender.ContextKey = ddlpState.SelectedItem.ToString();

   }


--------------------------------------------------------------------------
This one is AppCode class file:
XML
[WebMethod]
   public List<string> GetEmployeeNamesByState(string prefixText, string contextKey)
   {
       getAutoCompleteResponse = AutoCompleteService.GetEmployeeNamesByState(prefixText, contextKey);
       List<string> ProviderNames = new List<string>();
       foreach (var s in from item in getAutoCompleteResponse.AutoCompleteList
                         select new { code = item.Name })
       {
           ProviderNames.Add(s.code);

       }
       return ProviderNames;
   }
 
Share this answer
 

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



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