Friday, 15 June 2012

AJAX AutoCompleteExtender: Pass Additional Parameter using ContextKey


<cc1:AutoCompleteExtender ServiceMethod="SearchCustomers" MinimumPrefixLength="2"
        CompletionInterval="100" EnableCaching="false" CompletionSetCount="10" TargetControlID="txtContactsSearch"
        UseContextKey="true" ID="AutoCompleteExtender1" runat="server" FirstRowSelected="false">
    </cc1:AutoCompleteExtender>

<asp:TextBox ID="txtContactsSearch" runat="server" onkeyup = "SetContextKey()"></asp:TextBox>

javascript



<script type="text/javascript">
function SetContextKey()  {
      $find('AutoCompleteExtender1').set_contextKey($get("<%=ddlCountries.ClientID%>").value);
}
</script>


c#

[System.Web.Script.Services. ScriptMethod ()]
[System.Web.Services. WebMethod]
public static List<string> SearchCustomers(string prefixText, int count, string contextKey)
{
        //do something

}






No comments:

Post a Comment