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?
ddlEntType= '<%= rddlEnterprise.ClientID %>
but it is giving me "undefined" as the result.
Can you please provide the solution for this?
11 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 14 Aug 2013, 09:39 AM
Hi Ramandeep,
Please have a look at the following code I tried to alert the RadDropDownList selected value.
JavaScript:
Thanks,
Princy.
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.
0
Ramandeep
Top achievements
Rank 1
answered on 15 Aug 2013, 12:06 AM
I tried working out with the solution but i am still getting "undefined" result.
0
Kurt Kluth
Top achievements
Rank 1
answered on 28 Aug 2014, 09:16 PM
Was there ever a solution to this problem?
I am experiencing the same problem that I get "undefined".
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>
0
Princy
Top achievements
Rank 2
answered on 29 Aug 2014, 05:36 AM
Hi Kurt Kluth,
Please try the below JavaScript to achieve your scenario.
JavaScript:
Thanks ,
Princy.
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.
0
Kurt Kluth
Top achievements
Rank 1
answered on 29 Aug 2014, 12:25 PM
Princy,
Thank you. It worked like a charm.
Thank you. It worked like a charm.
0
bhargavi
Top achievements
Rank 1
answered on 05 Jun 2015, 08:04 AM
how to validate rad dropdownlist to take value on clientclick asp:net button
0
Hello,
The code snippet below demonstrates how you can validate a RadDropDownList on the client:
Regards,
Ivan Danchev
Telerik
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
0
bhargavi
Top achievements
Rank 1
answered on 05 Jun 2015, 04:40 PM
i am unable to access raddatepicker in external js file.please help
0
Santiago
Top achievements
Rank 1
answered on 18 Dec 2017, 08:30 PM
I think you need to use .control.
At least that worked for me. This is an example not using JQuery, using GelElementByID (and Im almost sure the JQuery function is a shortcut to GetElementById)
var dropBox = document.getElementById("<%=ddlDescription.ClientID %>");alert(dropBox.control.get_selectedItem().get_value());
Hope this helps
0
Damian
Top achievements
Rank 1
answered on 04 Aug 2018, 05:34 PM
Has anyone running into a scenario where the suggested solutions work well except in an iOS device?
mine keeps return the default value.
0
Hi Damian,
I would suggest that you use the findControl() method in order to access the Telerik controls client-side. Another approach would be to use client-side event handlers of the Telerik controls to get a reference to their objects.
For further reference you can have a look at the Access Telerik Controls on Client-Side help article.
Kind regards,
Tsvetomir
Progress Telerik
I would suggest that you use the findControl() method in order to access the Telerik controls client-side. Another approach would be to use client-side event handlers of the Telerik controls to get a reference to their objects.
For further reference you can have a look at the Access Telerik Controls on Client-Side help article.
Kind regards,
Tsvetomir
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
