Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

How to get SelectedValue (not the SelectedText) in Ajax ComboBox

$
0
0

I am trying to get the SelectedValue from the Ajax Control Toolkit ComboBox. I noticed that the rendered HTML items for the combobox are bulletlists (<li>) items. A hiddenfield is rendered but this object holds the selectedindex not the selectedvalue. I need the selectedvalue to do some javascript programming.  The combobox is as follows:

<asp:ComboBox ID="ddlTest" Enabled="false"  runat="server">

        <asp:ListItem Text="Red" Value="1"></asp:ListItem>
        <asp:ListItem Text="White" Value="2"></asp:ListItem>
        <asp:ListItem Text="Black" Value="3"></asp:ListItem>
            </asp:ComboBox>

P.S. I have a databound combobox.

Here is the code snippet that I am using:

var dropDownList = document.getElementById(drlElementID);

var comboTextBox = dropDownList.control.get_textBoxControl();

var hiddenFieldID = dropDownList.control.get_hiddenFieldControl();

hiddenField.value gives the SelectedIndex and not the SelectedValue.

 

Any help on this is highly appreciated.


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>