This is a migrated thread and some comments may be shown as answers.

Need to change backcolor of combobox.

3 Answers 60 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
hchattaway
Top achievements
Rank 1
hchattaway asked on 03 Sep 2008, 02:42 PM
Hello

I am looking to change the color of one combobox when the value of another combobox changes.

i.e. cmbOne is changed from "Select..." to "Entered Date", on the client side, I'd like to change the backcolor of cmbTwo to red to show it is now required... Any examples of how to do that?

This is the script I am using now... it can not resolve the $find("cmbCompare") statement in line 4, even though that control exists on the page...I have this hooked up to the "onselectedindexchanged" client event.

<script language="javascript" type="text/javascript"
    //<![CDATA[ 
    function SetCompareRed(sender, eventArgs) { 
        var compareChoice = $find("cmbCompare"); 
        compareChoice.BackColor = "Red"
    } 
    //]]> 
</script> 

Thanks for any help!
Harold

3 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 03 Sep 2008, 03:06 PM
Hi hchattaway,

Please try finding the combobox in this way:

var compareChoice = $find("<%= cmbCompare.ClientID %>");  

Also, please check this help article:
Tutorial: Change the appearance of the Input element

I hope this helps.

Kind regards,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
hchattaway
Top achievements
Rank 1
answered on 03 Sep 2008, 03:59 PM
Hello
<<
  var
 compareChoice = $find("<%= cmbCompare.ClientID %>"); 
>>

I had done that before but when I do I get this error when the page is loading...

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

I believe this is happening since this is in an ascx file in a DNN app, and this JS function is inside the FORM tag.. so it's being run during form load...How can I get that above the starting FORM tag if that is indeed the issue?

Thanks for the help!
Harold


0
Veselin Vasilev
Telerik team
answered on 04 Sep 2008, 07:43 AM
Hello hchattaway,

Please try wrapping the javascript within RadCodeBlock.

Kind regards,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
hchattaway
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
hchattaway
Top achievements
Rank 1
Share this question
or