AJAX C# AutoCompleteExtender contextKey

tjcombos picture tjcombos · Sep 17, 2009 · Viewed 18k times · Source

How do you dynamically pass parameter/control to contextKey?

<asp:TextBox ID="tbA" runat="server" autocomplete="off"></asp:TextBox> 
<asp:TextBox ID="tbB" runat="server">hello</asp:TextBox> 
<asp:TextBox ID="tbC" runat="server">world</asp:TextBox>

<cc1:AutoCompleteExtender ID="aceListA" ServiceMethod="myListServiceA" ServicePath="WebService.asmx" TargetControlID="tbA" runat="server" EnableCaching="true" UseContextKey="true"> </cc1:AutoCompleteExtender>

  [WebMethod]
   public string[] myListServiceA(string prefixText, int count, string contextKey)

Because I want to check tbB, tbC at Web Service level. I've read this article like 5 times, but still doesn't make a sense out of it, per half missing complete codes.

Answer

Terry Slack picture Terry Slack · Oct 6, 2009

You can set the context key in two ways:

Client-Side, through Javascript:

<script type="text/javascript">
    function SetContextKey()
    {
        $find('auJobs').set_contextKey('moo');
        return;
    }

</script>  `

or on the server side auJobs.ContextKey = "Whatever You need to put in here"

Terry