RadComboBox for ASP.NET AJAX

RadControls for ASP.NET AJAX

Instead of supplying an ItemsRequested event handler to add items on demand to RadComboBox, you can use a Web service to service the items request. The path to the Web service and the name of the service method are specified in the WebServiceSettings' Path and Method properties:

Note

RadComboBox input's Text can be obtained from the context object used by the WebService's method. The context object should be cast to IDictionary type, first.

CopyC#
public RadComboBoxItemData[] GetProducts(object context)
{
    IDictionary<string, object> contextDictionary = (IDictionary<string, object>)context;
    //Returns the Text of RadComboBox' input field.
    contextDictionary["Text"].ToString();
    //Returns the value set in the OnClientItemsRequesting event handler.
    contextDictionary["FilterString"].ToString();
}

public RadComboBoxData GetCompanyNames(RadComboBoxContext context)
{
    //Returns the Text of RadComboBox' input field.
    var comboText = context.Text;
}
CopyASPX
<script type="text/javascript">
    function OnClientItemsRequesting(sender, eventArgs) {
        var context = eventArgs.get_context();
        context["FilterString"] = eventArgs.get_text();
    }
</script>

<telerik:radcombobox 
    runat="server" 
    id="RadComboBox1" 
    width="300px" 
    enableloadondemand="true"
    onclientitemsrequesting="OnClientItemsRequesting">    
<WebServiceSettings Method="GetProducts" Path="Products.asmx" />
</telerik:radcombobox>

To use the integrated support, the Web service should have the following signature:

For a live example refer to the online demo: Populate From Web Service.

See Also