ASP.Net AJAX AutoCompleteExtender: Dynamically set ContextKey using JavaScript
 
Author:
Filed Under: ASP.Net  |  JavaScript  |  AJAX Control Toolkit
Published Date: Sep 27, 2011
Views: 2921
 

Abstract: Here Mudassar Ahmed Khan has explained how to dynamically set value of ContextKey for ASP.Net AJAX Control ToolKit AutocompleteExtender using JavaScript

Comments:  0

 

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.








Related Articles



Comments

No comments have been added to this article.

Add comments

You can add your comment about this article using the form below. Make sure you provide a valid email address
else you won't be notified when the author replies to your comment

Please note that all comments are moderated and will be deleted if they are
  • Not relavant to the article
  • Spam
  • Advertising campaigns or links to other sites
  • Abusive content.
Please do not post code, scripts or snippets.

Name*: Required
Email*: Required
Comment*: Required
Security code*: CaptchaInvalid Security Code
  Submit