Get all items of RadListBox

3 posts, 2 answers
  1. Abhi Shinde
    Abhi Shinde avatar
    56 posts
    Member since:
    May 2010

    Posted 25 Jan 2012 Link to this post

    Hi,,
    I am using RadListBox, I want to get all values of listbox.
    I am tying to use "get_items" method But it is showing foll. error.
    Uncaught TypeError: Object [object Object] has no method 'get_items' 
     
    ASPX code
    <script type="text/javascript" charset="utf-8">
            $(document).ready(function() {
     
     $('#<%=btnViewAssignedSlots.ClientID %>').click(function() {
                   var list = $('#<%= rdLstSource.ClientID %>');
                    var items = list.get_items();
                   var firstItem = items.getItem(0);
                    alert(firstItem);
    }
     
    });
        </script>

    <telerik:RadListBox runat="server" ID="rdLstSource" Height="200px" Width="230px"
                            AutoPostBackOnTransfer="false" AllowTransfer="true" TransferToID="rdLstDestination"
                            AllowTransferOnDoubleClick="true" EnableDragAndDrop="true" ButtonSettings-ShowTransferAll="true">
                            <Items>
                                <telerik:RadListBoxItem Text="Sunday" Value="1" />
                                <telerik:RadListBoxItem Text="Monday" Value="2"/>
                                <telerik:RadListBoxItem Text="Tuesday" Value="3"/>
                                <telerik:RadListBoxItem Text="Wednesday" Value="4"/>
                                <telerik:RadListBoxItem Text="Thursday" Value="5"/>
                                <telerik:RadListBoxItem Text="Friday" Value="6"/>
                                <telerik:RadListBoxItem Text="Saturday" Value="7"/>
                            </Items>
                        </telerik:RadListBox>

    Please help me to solve.
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Jan 2012 Link to this post

    Hello,

    Try the following javascript.
    JS:
    <script type="text/javascript">
        function OnClientClick()
         {
            var list = $find("<%=RadListBox1.ClientID %>");
            for (i = 0; i < list.get_items().get_count(); i++)
            {
              alert(list.getItem(i).get_value());
            }
        }
        </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Bozhidar
    Admin
    Bozhidar avatar
    1102 posts

    Posted 25 Jan 2012 Link to this post

    Hi Abhi,

    Please review the following help article, showing how to work with the RadListBox client object:
    http://www.telerik.com/help/aspnet-ajax/listbox-client-side-basics.html 
     
    All the best,
    Bozhidar
    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
Back to Top