Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ListBox > set index from java script

Not answered set index from java script

Feed from this thread
  • Posted on Apr 27, 2012 (permalink)

    Hello, I try from client side (java script) set index for RadListBox.

    How can I use document.getElementById for finding and set index for RadListBox ?

    regards,
    Dominik Kolcio

    Reply

  • Posted on Apr 27, 2012 (permalink)

    Hi Dominik,

    You can access the RadListBox using $find method and get the index as shown below.

    JS:
    <script type="text/javascript">
        function pageLoad()
        {
            var list = $find("<%= RadListBox1.ClientID %>");
            var items = list.get_items();
            list.trackChanges();
            var item = new Telerik.Web.UI.RadListBoxItem();
            item.set_text("New");
            item.set_value("Value");
            items.add(item);
            list.commitChanges();
            alert(item.get_index());
        }
    </script>

    Thanks,
    Shinu.

    Reply

  • Say Hello to Telerik's PivotGrid for ASP.NET AJAX, Silverlight, WPF and WinForms. Now packed with OLAP support.
  • Posted on Apr 27, 2012 (permalink)

    Yes, I try this before.
    When try to run app:
    The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

    But this problem I solved with RadScriptBlock.

    but I still can't set index in RadListBox from java script :(
    I don't need add any Items, because my RadListtBox is populated with data.

    I need select item by index.

    Reply

  • Posted on Apr 27, 2012 (permalink)

    I solved the problem.

    With clearSelection
    getItem and select

    thank you Shinu

    Dominik

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ListBox > set index from java script
Related resources for "set index from java script"

ASP.NET ListBox Features  |  Documentation  |  Demos  | Step-by-step Tutorial  ]