Can't Get Value Using Web Service

2 posts, 0 answers
  1. Ken Cox
    Ken Cox avatar
    100 posts
    Member since:
    Oct 2002

    Posted 06 Sep 2013 Link to this post

    I'm adapting the load on demand from web service example. I'm adding an ID property and trying get the current/selected value (not the text!) from the combobox. It doesn't seem to be there.

    I've pasted in the code so far. Could someone tell me what I'm doing wrong that the ID never shows up when calling get_value()?

    using System.Collections;
    using System.Collections.Generic;
    using System.Web.Script.Services;
    using System.Web.Services;
    using Telerik.Web.UI;
    [WebService(Namespace = "")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class ComboBoxWebService : WebService
        public IEnumerable GetItems(RadComboBoxContext context)
            RadComboBoxData result = new RadComboBoxData();
            int numberOfItems = (int)(context["ItemsCount"] ?? 1000);
            List<ComboBoxItemData> items = new List<ComboBoxItemData>();
            for (int i = 0; i < numberOfItems; i++)
                ComboBoxItemData itemData = new ComboBoxItemData();
                itemData.Text = "Item " + i;
                itemData.ID = i;
            return items;
    public class ComboBoxItemData
        private string text;
        private int id;
        public string Text
            get { return text; }
            set { text = value; }
        public int ID
            get { return id; }
            set { id = value; }

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="DefaultCS" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html>
    <head runat="server">
        <form id="form1" runat="server">
                <label>Number of items to load:</label>
                <asp:ScriptManager runat="server"></asp:ScriptManager>
                <telerik:RadNumericTextBox runat="server" ID="ItemsCountTextBox" Width="60"
                    Value="1000" MaxValue="4000" MinValue="100" ShowSpinButtons="True">
                    <NumberFormat DecimalDigits="0" />
                <telerik:RadComboBox runat="server" ID="RadComboBox1" Width="240" Height="200px"
                    DataTextField="Text" DataValueField="id" OnClientItemsRequested="OnClientItemsRequested"
                    OnClientItemsRequesting="OnClientItemsRequesting" AppendDataBoundItems="true"
                    EnableLoadOnDemand="true" EnableItemCaching="true">
                    <ExpandAnimation Type="none" />
                    <CollapseAnimation Type="none" />
                    <WebServiceSettings Path="ComboBoxWebService.asmx" Method="GetItems" />
                <telerik:RadScriptBlock runat="Server" ID="RadScriptBlock1">
                    <script type="text/javascript">
                        var startTime;
                        var sendRequest = true;
                        var calculate = false;
                        function OnClientItemsRequesting(sender, args) {
                            var input = $find("<%= ItemsCountTextBox.ClientID %>");
                            args.get_context()["ItemsCount"] = input.get_value();
                            startTime = new Date();
                        function OnClientItemsRequested(sender, args) {
                            var endTime = new Date();
                            //         $get("total").innerHTML = endTime - startTime + "ms";
                        function OnClientDropDownClosed(sender, args) {
                            if (args.get_domEvent().stopPropagation)
                        function GetCurrentValue(sender, args) {
                            var combo = $find("<%= RadComboBox1.ClientID %>");
                <telerik:RadButton ID="btnSelect" runat="server" Text="Select" OnClientClicked="GetCurrentValue">
  2. Plamen
    Plamen avatar
    2725 posts

    Posted 11 Sep 2013 Link to this post

    Hi Ken,

    Thank you for contacting Telerik support.

    Here is the code that I changed at my side with the code that you shared in order to show the selected in RadComboBox text:

    function GetCurrentValue(sender, args) {
                          var combo = $find("<%= RadComboBox1.ClientID %>");

    Hope this will be helpful. if you have further questions please don't hesitate to contact us again.

    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. DevCraft R3 2016 release webinar banner
Back to Top