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

Custom parameter for WebMethod

3 Answers 255 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Sandeep
Top achievements
Rank 1
Sandeep asked on 06 Feb 2013, 09:03 AM
Hi,

I am using RadAutoCompleteBox (Q3 2012 SP2) & Binding it with WebMethod like:
<telerik:RadAutoCompleteBox ID="rdtxt" runat="server" Width="90%" EmptyMessage="enter country to search" InputType="Token" Filter="StartsWith" AllowCustomEntry="true">
<TextSettings SelectionMode="Single" />
<WebServiceSettings Method="GetCountries" Path="frmPage1.aspx" />
</telerik:RadAutoCompleteBox>
It works fine. Fetching countries from server method GetCountries().

Now, I want to fetch State for that selected/entered country.
How to pass that country to WebMethod of GetState(object countryData) ?

Plz reply asap.

3 Answers, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 11 Feb 2013, 08:11 AM
Hello Sandeep,

As far as I understand - you want to pass a parameter to the WebService Method that you use to populate the RadAutoCompleteBox with data.
You can make this by handling the OnClientRequesting event handler and attach the parameter to the RadAutoCompleteContext in this way:


<script type="text/javascript">
 
          function OnClientRequesting(sender, eventArgs) { debugger;
               var context = eventArgs.get_context();
                  context["Country"] = "UK";
              }
 
      </script>
      <telerik:RadAutoCompleteBox runat="server" ID="RadAutoCompleteBox1"
          OnClientRequesting="OnClientRequesting">
          <WebServiceSettings Path="LoadEntries.asmx" Method="GetNames" />
      </telerik:RadAutoCompleteBox>

[WebMethod]
public AutoCompleteBoxData GetNames(RadAutoCompleteContext context)
{
    string name = context["Country"].ToString();
    ...
    ...
    ...
    }

Regards,
Kalina
the Telerik team
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 their blog feed now.
0
Sandeep
Top achievements
Rank 1
answered on 04 Mar 2013, 10:31 AM
Thanks Kalina,

One more thing, Can I use PageHandlers (.ashx) instead of WebMethod to bind AutoComplete control ?

Like: GenericPageHandler.ashx?src=autoCmplt

& return json object from code.
0
Nencho
Telerik team
answered on 07 Mar 2013, 08:50 AM
Hello Sandeep,

Using a Generic Handlers to bind the RadAutoCompleteBox is not a supported scenario. Therefor, I can suggest you to use the WebMethod, as you intended to do.

Greetings,
Nencho
the Telerik team
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 their blog feed now.
Tags
AutoCompleteBox
Asked by
Sandeep
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Sandeep
Top achievements
Rank 1
Nencho
Telerik team
Share this question
or