Here I am explaining how to set or assign the value of ContextKey parameter for ASP.Net AJAX AutoCompleteExtender from Client Side using JavaScript
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
 
<!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>
    <script type="text/javascript">
        function SetContextKey() {
            $find('<%=AutoCompleteExtender1.ClientID>%').set_contextKey("221");
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:TextBox ID="txtContactsSearch" runat="server" onkeyup="SetContextKey()"></asp:TextBox>
    <cc1:AutoCompleteExtender ServiceMethod="SearchCustomers" MinimumPrefixLength="2"
        CompletionInterval="100" EnableCaching="false" CompletionSetCount="10" TargetControlID="txtContactsSearch"
        UseContextKey="true" ID="AutoCompleteExtender1" runat="server" FirstRowSelected="false">
    </cc1:AutoCompleteExtender>
    </form>
</body>
</html>
 
 
Explanation:
Above I am setting the ContextKey property of the ASP.Net AJAX AutoCompleteExtender on the onkeyup event of the ASP.Net TextBox using the SetContextKey JavaScript function.