setting label value to selected combobox value?

3 posts, 1 answers
  1. Garrett
    Garrett avatar
    35 posts
    Member since:
    Feb 2012

    Posted 26 Sep 2013 Link to this post

    HI there! Pretty simple question and probably very simple answer, haha.

    I have a combo box that has a couple of values in it (Invoice, Quote). I also have a label or two.

    I'd like to set the labels to whatever the combobox is currently set to.

    By default the box is set to Invoice, so the page would go something like:

    Is this an invoice or a quote? [RadComboBox:Invoice]
    Ok, this will be marked as [Label:Invoice].

    If the user clicks the combobox and selects Quote, I would like the label to also change to Quote without having to submit anything, just change the label on the fly as the combo box changes.

    I assume I would need to use the RadComboBox_DropDownClosing function? 
  2. Answer
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Sep 2013 Link to this post

    Hi Garrett,

    Please try the following code snippet that I tried to change the label according to RadComboBox selectedItem in OnClientDropDownClosing event.

    <telerik:RadComboBox ID="RadComboBox1" runat="server" OnClientDropDownClosing="OnClientDropDownClosing1">
            <telerik:RadComboBoxItem Text="Invoice" runat="server" Selected="true" />
            <telerik:RadComboBoxItem Text="Quote" runat="server" />
    <asp:Label ID="Label1" runat="server" Text="Invoice">

    <script type="text/javascript">  
     function OnClientDropDownClosing1(sender, args) {
            var label = document.getElementById("Label1");
            label.textContent = sender._selectedItem._text;

  3. DevCraft R3 2016 release webinar banner
  4. Garrett
    Garrett avatar
    35 posts
    Member since:
    Feb 2012

    Posted 27 Sep 2013 Link to this post

    Hi Shinu, 

    thank you for your help, it seems that when I use your snippet the radcombobox stays open, never closing even when the control loses focus. I wonder if maybe I should use another event to trigger the change?

    Edit: I just tried it in a new blank page and it worked, must be something I am doing wrong......I think it is because I am using a masterpage and it is somehow screwing with it........

    I will look into this, thank you again Shinu
Back to Top