change background

2 posts, 0 answers
  1. Dawson
    Dawson avatar
    45 posts
    Member since:
    Sep 2013

    Posted 18 Jun 2014 Link to this post

    Hi,
    I have a scenario.. How can i change the background color of a radcombox with change in selected item from client side.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Jun 2014 in reply to Dawson Link to this post

    Hi Dawson,

    Try the following code to achieve your scenario.

    ASPX:

    <telerik:RadComboBox runat="server" id="RadComboBox1" OnClientSelectedIndexChanged="OnClientSelectedIndexChanged" >
             <Items>
                    <telerik:RadComboBoxItem Text="red" Value="red" />
                    <telerik:RadComboBoxItem Text="blue" Value="blue" />
                    <telerik:RadComboBoxItem Text="green" Value="green" />
                    <telerik:RadComboBoxItem Text="yellow" Value="yellow" />
             </Items>
    </telerik:RadComboBox>

    Javascript:

    function OnClientSelectedIndexChanged(sender, args)
            {
                sender.get_inputDomElement().style.backgroundColor = args.get_item().get_value();
            }

    Thanks,
    Shinu
Back to Top