Using jQuery to get RadDropDownList value

9 posts, 0 answers
  1. Ramandeep
    Ramandeep avatar
    2 posts
    Member since:
    Aug 2013

    Posted 14 Aug 2013 Link to this post

    I am trying to get the value of selected item from a RadDropDownList using the below code snippet:
    ddlEntType= '<%= rddlEnterprise.ClientID %>

    but it is giving me "undefined" as the result.

    Can you please provide the solution for this?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 14 Aug 2013 Link to this post

    Hi Ramandeep,

    Please have a look at the following code I tried to alert the RadDropDownList selected value.

    JavaScript:
    <script type="text/javascript">
        function getdropdownlistSelectedItem(sender, args) {
            var raddropdownlist = $find('<%=RadDropDownList1.ClientID %>');
            var selecteditem = raddropdownlist.get_selectedItem().get_value();
            alert(selecteditem);
        }
    </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ramandeep
    Ramandeep avatar
    2 posts
    Member since:
    Aug 2013

    Posted 14 Aug 2013 Link to this post

    I tried working out with the solution but i am still getting "undefined" result. 
  5. Kurt Kluth
    Kurt Kluth avatar
    144 posts
    Member since:
    Oct 2009

    Posted 28 Aug 2014 in reply to Ramandeep Link to this post

    Was there ever a solution to this problem?

    I am experiencing the same problem that I get "undefined".

        function getdropdownlistSelectedItem(sender, args) {
            var valueFind = $find("<%=Restaurants.ClientID%>").get_selectedItem().get_value();
            alert(valueFind);
        }
     
    <telerik:RadDropDownList ID="Restaurants" name="placetype" runat="server" DefaultMessage="Select Restaurant" OnClientItemSelected="getdropdownlistSelectedItem">
           <Items>
                 <telerik:DropDownListItem runat="server" Text="All Restaurants" Value="Restaurants"></telerik:DropDownListItem>
                 <telerik:DropDownListItem runat="server" Text="American" Value="American Restaurants"></telerik:DropDownListItem>
                 <telerik:DropDownListItem runat="server" Text="Asian" Value="Asian Restaurants"></telerik:DropDownListItem>
                 <telerik:DropDownListItem runat="server" Text="French" Value="French Restaurants"></telerik:DropDownListItem>
                 <telerik:DropDownListItem runat="server" Text="German" Value="German Restaurants"></telerik:DropDownListItem>
                 <telerik:DropDownListItem runat="server" Text="Indian" Value="Indian Restaurants"></telerik:DropDownListItem>
                 <telerik:DropDownListItem runat="server" Text="Italian" Value="Italian Restaurants"></telerik:DropDownListItem>
                 <telerik:DropDownListItem runat="server" Text="Mediterranean" Value="Mediterranean Restaurants"></telerik:DropDownListItem>
                 <telerik:DropDownListItem runat="server" Text="Mexican" Value="Mexican Restaurants"></telerik:DropDownListItem>
            </Items>
    </telerik:RadDropDownList>
       

     

     

     

  6. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 29 Aug 2014 in reply to Kurt Kluth Link to this post

    Hi Kurt Kluth,

    Please try the below JavaScript to achieve your  scenario.

    JavaScript:
    function getdropdownlistSelectedItem(sender, args) {
        var count, length = sender.get_items().get_count();
        for (count = 0; count < length; count++) {
            if (sender.get_items()._array[count].get_selected()) {
                alert(sender.get_items()._array[count].get_value());
            }
        }
    }

    Thanks ,
    Princy.
  7. Kurt Kluth
    Kurt Kluth avatar
    144 posts
    Member since:
    Oct 2009

    Posted 29 Aug 2014 in reply to Princy Link to this post

    Princy,

    Thank you.  It worked like a charm. 

  8. bhargavi
    bhargavi avatar
    5 posts
    Member since:
    Apr 2015

    Posted 05 Jun 2015 in reply to Princy Link to this post

    how to validate rad dropdownlist to take value on clientclick asp:net button
  9. Ivan Danchev
    Admin
    Ivan Danchev avatar
    832 posts

    Posted 05 Jun 2015 Link to this post

    Hello,

    The code snippet below demonstrates how you can validate a RadDropDownList on the client:
    <telerik:RadDropDownList ID="RadDropDownList1" runat="server">
        <Items>
            <telerik:DropDownListItem Text="" />
            <telerik:DropDownListItem Text="Tokyo" />
            <telerik:DropDownListItem Text="Osaka" />
            <telerik:DropDownListItem Text="Yokohama" />
            <telerik:DropDownListItem Text="Kyoto" />
        </Items>
    </telerik:RadDropDownList>
     
    <asp:Button ID="Button1" OnClientClick="return ValidateDropDownList();"
        runat="server" Text="Validate" />
     
    <script type="text/javascript">
     
        function ValidateDropDownList() {
     
            var isSelected = false;
            var dropDown = $find("<%= RadDropDownList1.ClientID %>");
            var selectedText = dropDown.get_selectedItem().get_text();
            if (selectedText != "") {
                isSelected = true;
            }
            else {
                alert("Select a city!");
            }
            return isSelected;
        }
    </script>

    Regards,
    Ivan Danchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  10. bhargavi
    bhargavi avatar
    5 posts
    Member since:
    Apr 2015

    Posted 05 Jun 2015 in reply to Ivan Danchev Link to this post

    i am unable to access raddatepicker in external js file.please help
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017