最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

asp.net - Is it possible to set the selected value in a Telerik RadDropDownList in Javascript? - Stack Overflow

programmeradmin3浏览0评论

Is it possible to set the selected value/item in a Telerik RadDropDownList in Javascript?

I'm looking at the documentation .html and it seems there is no documented way to do this simple and essential task.

Is it simply not in the documentation? Tried searching the forums as well to no avail.

Is it possible to set the selected value/item in a Telerik RadDropDownList in Javascript?

I'm looking at the documentation http://www.telerik./help/aspnet-ajax/dropdownlist-clientsideprogramming-clientsidebasic.html and it seems there is no documented way to do this simple and essential task.

Is it simply not in the documentation? Tried searching the forums as well to no avail.

Share Improve this question asked Sep 30, 2013 at 18:22 user2320724user2320724 6863 gold badges10 silver badges18 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 13

You can use select() or set_selected(true) function. Here is the documentation.

<telerik:RadDropDownList ID="RadDropDownList1" runat="server">
    <Items>
        <telerik:DropDownListItem runat="server" Text="One" Value="1" />
        <telerik:DropDownListItem runat="server" Text="Two" Value="2" />
        <telerik:DropDownListItem runat="server" Text="Three" Value="3" />
    </Items>
</telerik:RadDropDownList>
<script type="text/javascript">
    function pageLoad() {
        var dropdownlist = $find("<%= RadDropDownList1.ClientID %>");
        var item = dropdownlist.findItemByValue("3");
        item.select();
    }
</script>
var dropdownlist = document.getElementById('<%= RadDropDownList1.ClientID %>');
if (dropdownlist != null) {
    dropdownlist .children[0].children[0].innerHTML = "3 - Low";
    dropdownlist .children[0].children[0].setAttribute("class", "rddlFakeInput");
}

No other solutions worked on my project !! 3 days for the item.selected = true; it's not acceptable, so JavaScript in 20 minutes

发布评论

评论列表(0)

  1. 暂无评论