views:

2841

answers:

1

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="listA" ServicePath="WebService.asmx" TargetControlID="tbA" runat="server" EnableCaching="true" UseContextKey="true"> </cc1:AutoCompleteExtender>

  [WebMethod]
   public string[] listAs(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.

+1  A: 

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

TGS
I meant to add, 'auJobs' is the IDof your autocomplete extender. You can also give your autocomplete extender a BehaviorID and use that instead of the id to find it. Hope this helps
TGS