This is a migrated thread and some comments may be shown as answers.

Passing data to context in RadAutoCompleteBox throws an error

1 Answer 142 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Billy
Top achievements
Rank 1
Billy asked on 10 Dec 2013, 12:45 AM

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.


1 Answer, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 12 Dec 2013, 12:27 PM
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.
Tags
AutoCompleteBox
Asked by
Billy
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Share this question
or