Change DropDownList from client

3 posts, 1 answers
  1. Daniel
    Daniel avatar
    175 posts
    Member since:
    Feb 2009

    Posted 21 Jan 2014 Link to this post

    Hi, is it possible to change the selected index from javascript? I can't see it in the doco. Daniel.
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 21 Jan 2014 Link to this post

    Hi Daniel,

    Please have a look into the sample code snippet to change the RadDropDownList item from the client side.

    ASPX:
    <telerik:RadDropDownList ID="RadDropDownList1" runat="server">
        <Items>
            <telerik:DropDownListItem Text="Item1" />
            <telerik:DropDownListItem Text="Item2" />
            <telerik:DropDownListItem Text="Item3" />
            <telerik:DropDownListItem Text="Item4" />
        </Items>
    </telerik:RadDropDownList>

    JavaScript:
    <script type="text/javascript">
        function pageLoad() {
            var index = 2; // index of the dropdownlistitem want to select
            var list = $find("<%=RadDropDownList1.ClientID %>");
            list.get_items().getItem(index).select();
        }
    </script>

    Hope this will helps you.
    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Daniel
    Daniel avatar
    175 posts
    Member since:
    Feb 2009

    Posted 21 Jan 2014 Link to this post

    Thanks Princy.
Back to Top