Passing data to context in RadAutoCompleteBox throws an error

2 posts, 0 answers
  1. Billy
    Billy avatar
    2 posts
    Member since:
    Jun 2013

    Posted 09 Dec 2013 Link to this post

    How to pass additional data to context from RadAutoCompleteBox

    This is on my markup, the retrieval of data is working but passing the data to context from the RadAutoCompleteBox has a problem.

    <
    telerik:RadAutoCompleteBox
       ID="racbTest"
       runat="server"
       DataTextField="Text"
       AutoPostBack="False"
       TextSettings-SelectionMode="Single"
       OnClientItemsRequesting="TestRequesting"
       InputType="Text"
       AllowCustomEntry="True">
       <WebServiceSettings
           Path="../DataSources/DataLoader.asmx"
           Method="SearchTest">
       </WebServiceSettings>
    </telerik:RadAutoCompleteBox>
     
    <telerik:RadCodeBlock runat="server">
       <script>
          function TestRequesting(sender, args) {
             args.get_context()["Foo"] = "Bar";
          }
       </script>
    </telerik:RadCodeBlock>


    and this is the code in the web service

    [WebMethod]
    public AutoCompleteBoxData SearchTest(RadAutoCompleteContext context)
    {
       string searchString = context.Text;
       string foo = context["Foo"].ToString();
    }

    the problem is in the WebMethod, the context["Foo"] throws an error that

    The given key was not present in the dictionary.

    Any help would be appreciated.. Thanks in advance.


  2. Bozhidar
    Admin
    Bozhidar avatar
    1102 posts

    Posted 12 Dec 2013 Link to this post

    Hi Virgilio,

    The problem here is the name of the event - in RadAutoCompleteBox it's called OnClientRequesting. Since you are using the OnClientItemsRequesting name, the event it never triggered and the "Foo" key is not added to the dictionary.

    Regards,
    Bozhidar
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top